Question: In this problem, you will write a class to implement a very simple word processor ( only one line of text is allowed ) .
In this problem, you will write a class to implement a very simple word processor only
one line of text is allowed
a Write the class LineEditor which stores a line of text a list of characters as
well as a cursor position an iterator into the list The cursor is allowed to point
to any character in the line of text, as well as one character after the line. Use
the file names LineEditor.h and LineEditor.cc
Your class should provide the following member functions:
Default constructor: initializes an empty line of text. The cursor should be
placed one character past the end of the line.
void left: moves the cursor to the left by one character. If the cursor is
already at the beginning, this function does nothing.
void right: moves the cursor to the right by one character. If the cursor
is already pointing to one character past the end, this function does nothing.
void insertconst string& s: inserts the string s into the current position.
The cursor should be positioned after the inserted string. Note: the
iterator remains unchanged and valid after list::insert so it does
not need updating.
void erase: erases the character at the current position. The cursor
should be positioned at the character immediately after the one erased. If
the cursor is past the end of the line, this function does nothing.
void changechar c: changes the character at the current position to c
The cursor should be positioned at the changed character. If the cursor points
to one past the end of the line, then this function should behave exactly the
same way as insert.
void applychar fchar c: applies the function f to every character
c in the line, and replaces the character by fc
Also provide a friend function to print the line:
ostream& operatorostream& os const LineEditor& le;
The line of text is first printed, ended with the symbol $ to mark the end of line.
The next line contains a single character to indicate the position of the cursor.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
