Question: Please use C++ for this Header File #ifndef CURSOR_H #define CURSOR_H // Cursor class. // ******************PUBLIC OPERATIONS******************************************************************************** // bool isEmpty( ) --> Return true if

Please use C++ for this

Please use C++ for this Header File #ifndef CURSOR_H #define CURSOR_H //Cursor class. // ******************PUBLIC OPERATIONS******************************************************************************** // bool isEmpty( ) --> Return trueif empty; else false // void makeEmpty( ) --> Remove all items

Header File

#ifndef CURSOR_H #define CURSOR_H // Cursor class. // ******************PUBLIC OPERATIONS******************************************************************************** // bool isEmpty( ) --> Return true if empty; else false // void makeEmpty( ) --> Remove all items // void left( ) --> Move cursor one position left or do nothing if already at beginning of text // void right( ) --> Move cursor one position right or do nothing if already at end of text // void del( ) --> Delete node after current cursor position or do nothing if already at end of text // void back( ) --> Remove node before current cursor position or do nothing if already at beginning of text // void insert( x ) --> Insert x after current cursor position // void home( ) --> Move cursor to the beginning of text or do nothing if already at beginning of text // void end( ) --> Move cursor to the end of text or do nothing if already at end of text // void undo( ) --> Undo the last delete/back/insert operation // *******************PRIVATE OPERATIONS****************************************************************************** // void printText ( ) --> This will print the entire contents of the list. This is a private member function. // This will be called by each of left(), right(), del(), back() and insert(). //******************************************************************************************************************** template  class Cursor; //forward declaration. template  class CNode { CNode( const Object & theElement = Object( ), CNode * n = nullptr ): element( theElement ), next( n ) { } Object element; CNode *next; friend class Cursor; }; template  class Cursor { public: Cursor( ); bool isEmpty( ) const; void makeEmpty( ); void left ( ); void right ( ); void del ( ); //This is the delete operation. I named it del instead of delete as delete conflicts with a C++ keyword. void back ( ); void insert( const Object & x ); void home ( ); void end ( ); void undo ( ); private: void printText ( ) ; CNode *header; CNode *cursorPosition; }; #endif

COMP 2810: HOMEWORK 2 (List ADT) Due Mon Sep 10 11:59 pm (Hard Deadline) In this assignment, you will create a class similar to the List ADT Simulate a simple text editor, which stores a string of characters using the List ADT which has been endowed with some additional features. We will call this endowed List ADT as a Cursor class. Normally, you would implement the Cursor class using inheritance, that is, the Cursor class would be a derived class of the List ADT which would serve as the base class. However, in this assignment we will implement the Cursor class from scratch and model it after the List ADT You must use a singly linked list. Do not use any iterators to traverse the list. The reason is I want you to manipulate the linked lists directly Your editor should support the following operations and redisplay the current text (that is, list) after performing any one of them. left move cursor left one character (or do nothing if at the beginning of the text) right move cursor right one character (or do nothing if at the end of the text) delete: delete the character to the right of the cursor (or do nothing if at the end of the text) back: delete the character to the left of the cursor (or do nothing if at the beginning of the text) insertc: insert the character c just after the cursor. home: move cursor to the beginning of the text (or do nothing if at the beginning of the text) end. move cursor to the end of the text (or do nothing if at the end of the text) undo: undo the last insert/delete/back operation (You can assume that between any two consecutive "undo" commands issued by the user, there will be at least one insert/delete/back operation.) The Cursor class definition is provided to you. You can only add member variables or COMP 2810: HOMEWORK 2 (List ADT) Due Mon Sep 10 11:59 pm (Hard Deadline) In this assignment, you will create a class similar to the List ADT Simulate a simple text editor, which stores a string of characters using the List ADT which has been endowed with some additional features. We will call this endowed List ADT as a Cursor class. Normally, you would implement the Cursor class using inheritance, that is, the Cursor class would be a derived class of the List ADT which would serve as the base class. However, in this assignment we will implement the Cursor class from scratch and model it after the List ADT You must use a singly linked list. Do not use any iterators to traverse the list. The reason is I want you to manipulate the linked lists directly Your editor should support the following operations and redisplay the current text (that is, list) after performing any one of them. left move cursor left one character (or do nothing if at the beginning of the text) right move cursor right one character (or do nothing if at the end of the text) delete: delete the character to the right of the cursor (or do nothing if at the end of the text) back: delete the character to the left of the cursor (or do nothing if at the beginning of the text) insertc: insert the character c just after the cursor. home: move cursor to the beginning of the text (or do nothing if at the beginning of the text) end. move cursor to the end of the text (or do nothing if at the end of the text) undo: undo the last insert/delete/back operation (You can assume that between any two consecutive "undo" commands issued by the user, there will be at least one insert/delete/back operation.) The Cursor class definition is provided to you. You can only add member variables or

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!