Simple Text Editor using Class

Write a simple text editor using class

Page 1 of 1

1 Replies - 14377 Views - Last Post: 08 December 2009 - 11:00 PM Rate Topic: -----

#1 cutebird   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-November 09

Simple Text Editor using Class

Posted 08 December 2009 - 09:18 PM

Write a simple line-by -line text editor. Each page contains 20 lines and each lines contains 100 characters. You may have up to 1000 pages. Start with page 1 and add more as needed. Each page should be dynamically created as needed. Create a page class and a editor class that create an array of 1000 pointers to Page class during construction of editor class. Actual page should be constructed when a new page is added. A page is displayed with page number on top and line number on left of each line. On bottom of page, show commands such as D: delete, E: edit
Here is what I have done and not sure how to proceed from here:

cons tint MAX_LINE = 20;
const int MAX_CHAR=100;
const int MAX_PAGES=1000;
class Page {
char aPage[MAX_LINE][MAX_CHAR];
void print();
void edit();
void edit_line(int i);
void delete_line(int i);
typedef Page *Pagestr;
class Editor{
Pagestr *Pages;
int cur;
int total;
void show_command();
void display_current_page();
void next();
void prev();
void edit();

Is This A Good Question/Topic? 0
  • +

Replies To: Simple Text Editor using Class

#2 Martyr2   User is online

  • Programming Theoretician
  • member icon

Reputation: 5223
  • View blog
  • Posts: 14,002
  • Joined: 18-April 07

Re: Simple Text Editor using Class

Posted 08 December 2009 - 11:00 PM

This is the part of the program where I start creating a main function that will test just my Page class. Then I fill in the pieces of the Page Class methods and test just that page class. Create a page instance, call its methods, make sure that works solid because the editor is going to rely on that class. Next I create an Editor instance and fill in its methods, giving it instances of my already build and tested page class.

Be sure to tackle this one class at a time starting with the Page class. Create your main to be a driver test program for this class....

int main() {

	 // Create instance of class
	 Page *page1 = new Page();

	 // Test some of its methods

	 // Cleanup
	 delete page1;


Essentially code up all the methods and test to make sure all parts of the Page class works as expected. Then move onto editor doing a similar test, but this time you have a fully tested Page class you can use to test Editor.

That will get you moving in the right direction. :)
Was This Post Helpful? 1

Page 1 of 1