Need help with my assignment

Here is what I have been asked to do:

a)Create a Document class to load the text document in memory. For this purpose the constructor of the class is in charge with creating a memory structure representing an array of pointers to string classes, each string class holding the content of one row. The array of pointers should grow by an increment of 10 each time it fills up with document’s rows. The document should be read from a text file, each sentence of the text file is captured in a string object. In the example below the text from the document is represented in abstract by rows of ‘a’, ‘b’, etc. This class should be tracking the size of the array of pointers, the number of rows loaded, and provide an interface getRow(int nr) function to return the content of a particular row (verify for document overflow).

b)Create a Display class that has a Document classs as member. The Constructor of the class will define the display area in terms of offset position from the top-left corner of the DOS window (the 5th row) and the height of the display area (10 rows). The Display class will get the keyboard input and move the DOS prompt based on the four arrows: Up, Down, Left, Right. Once the prompt reaches the top or bottom of the display area, the text is scrolled Down or Up respectively. To display the document’s content, the Display class will call repeatedly the getRow(nr) function The ESC button will terminate the program.

Here is what I have so far:

-----------------------------String.h------------------------------------------
#ifndef SIMPLESTRING_H
#define SIMPLESTRING_H

class simpleString
{
public:
simpleString();
virtual~simpleString();
void printString();
private:
char *theString;
};
#endif
---------------------------------String.cpp----------------------------------
#include<iostream>
#include"String.h"
using namespace std;

simpleString::simpleString()
{
theString = "hello";
}
simpleString::~simpleString()
{
theString = "NUll";
}
void simpleString::printString()
{
//cout<<theString<<endl;
}
----------------------------------Document.h-----------------------------------
#ifndef DOCUMENT_H
#define DOCUMENT_H
#include "String.h"
class Document
{
public:
Document();
virtual ~Document();
//simpleString getRow(int nr);
private:
simpleString *lines;
};

#endif
--------------------------------Document.cpp-----------------------------------
#include<iostream>
#include<fstream>
#include<string>
#include "Document.h"
#include "String.h"

using namespace std;
Document::Document()
{
int number_of_lines = 0;
std::ifstream file;
file.open("readme.txt");
std::string str;

while(std::getline(file, str,'.'))
{
++number_of_lines;
}
lines = new simpleString[number_of_lines];
//simpleString *lines[number_of_lines];
for(int i=0;i<number_of_lines; i++)
{
//lines[i] = new simpleString;
lines[i].theString = getline(file,str,'.');
}
}
/*simpleString Document::getRow(int nr)
{
return lines[nr];
}*/

---------------------------------Display.h-------------------------------------
#ifndef DISPLAY_H
#define DISPLAY_H
class Display
{
public:
Display(int Width, int Height);
~Display();
private:
Document *text;

};


#endif
---------------------------------Display.cpp-----------------------------------
#include<iostream>
#include<Windows.h>
#include"Display.h"
#include"Document.h"
#include"String.h"

using namespace std;

Display::Display(int Width, int Height)
{
_COORD coord;
coord.X = Width;
coord.Y = Height;

_SMALL_RECT Rect;
Rect.Top = 0;
Rect.Left = 0;
Rect.Bottom = Height - 1;
Rect.Right = Width - 1;

HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE); // Get Handle
SetConsoleScreenBufferSize(Handle, coord); // Set Buffer Size
SetConsoleWindowInfo(Handle, TRUE, &Rect); // Set Window Size
}
--------------------------main.cpp--------------------------------------------
#include<iostream>
#include "Document.h"
#include "String.h"

int main()
{
Document *doc = new Document();
char* newString = NULL;
return 0;
}


-------------------------------------------------------------------------------
The code is not compiling, I am not understanding where my errors are or what they mean. any help would be appreciated.


Topic archived. No new replies allowed.