I'm struggling with my current assignment at the moment, and I've been trying to find a solution for a while on reading in this complex file. I'm supposed to read it in to a tree. Preferably, I'd like to do that alphabetically, and if there's a way to do that, I'd appreciate some help. But for now, I'm just trying to get it into the nodes.
I looked up the documentation on using "file>>" but it doesn't really specify some of the more intricate details, such as which lines or characters will actually be read in. Spaces, returns, etc, are all a mystery to me. Here is what it looks like.
Matlock (1986-1995)
Mystery
http://www.imdb.com/title/tt0090481/
Andy Griffith
Nancy Stafford
Julie Sommars
Clarence Gilyard Jr.
Kene Holliday
For the algorithms I need to write for searching the tree, I'm going to need to somehow get the first full word into a string. The start year needs to go into an int, and the end year into an int, but how can I navigate around the parenthesis? Then I have to go to the next line to get the genre, then skip an entire line (I don't need the IMDB link), and then store all of the actors in their own strings. Each show has a different number of actors, so I'm going to need some sort of list or something that reads back into the tree so I can get "actor1, actor2," and so on. Those are the main parts I'm fairly clueless as to how to do them.
Here is my code for both a list class that I'm hoping to use to read out specific nodes later (and maybe I can use it to add actor names?) as well as the tree class.
TreeNode.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#pragma once
#include <iostream>
#include <string>
using namespace std;
struct BSTNode
{
string showName;
int startYear;
int endYear;
string genre;
string actorName;
BSTNode* left;
BSTNode* right;
};
|
LinkedList.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#pragma once
#include <iostream>
#include <string>
#include "TreeNode.h"
using namespace std;
class LinkedList
{
struct node
{
BSTNode linkedNode;
};
};
|