Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
You will make a simple line-by-line text editor. Each page contains 20 lines and each line contains up to 100 characters. You may have up to 1,000 pages, while it starts from only 1 page and adds more pages when user types in. Each page has to be dynamically created when needed. Create a Page class and the Editor class can create an array of 1000 pointers to the Page class during the construction of the Editor class. (Actual page should be constructed when a new page is added)
At each time, a page is displayed with page number on the top and the line numbers on the left side of each line. There is a command line at the bottom and it shows possible commands as shown below.
[commands: line number allows you to edit the line, „N‟ goes to next page, „P‟ goes to the previous page, „Dn‟ deletes the line n – D3 deletes line 3]____

Here's what I have done and not sure how to proceed from here:

const int MAX_LINE = 20;<br />
const int MAX_CHAR = 100;<br />
const int MAX_PAGES = 1000;<br />
class Page {<br />
char aPage[MAX_LINE][MAX_CHAR];<br />
public:<br />
void print();<br />
void edit();<br />
void edit_line(int i);<br />
void delete_line(int i);<br />
};<br />
typedef Page * PagePtr;<br />
class Editor {<br />
PagePtr *pages;<br />
int cur;<br />
int total;<br />
public:<br />
Editor();<br />
void show_commands();<br />
void display_cur_page();<br />
void next();<br />
void prev();<br />
void edit();<br />
};
Posted

This looks like you need to go back to your notes and study how to create methods inside your classes. For example the Page class will probably need some sort of constructor so when you create a new page it will set up some initial values. The edit method will need to accept text and add it to the page, allocating space for the text as it goes, etc. etc.
If you use Google to search for sample text editors you should find lots to help you.
 
Share this answer
 
Why the 1 vote guys ?

"Here's what I have done and not sure how to proceed from here:"

You couldn't just answer (as was done) politely with a suggestion of how to proceed ?

Too quick to vote.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900