Text Editor With OOP
Start Timer
0:00:00
You have been tasked with designing three classes: text_editor, moving_text_editor, and smart_text_editor. These classes are to be created with specific functionalities as defined below:
text_editorclass:write_line(string:str): A method which appends a given string to the end of the existing string.delete_line(char_num : int): A method which deleteschar_numnumber of characters from the existing string, starting from the end. If there are no characters left, the method should do nothing.special_operation(): A method which currently does nothing.get_notes(): A method which returns the internal string.
moving_text_editorclass:- This class extends
text_editor. Thespecial_operation()method is overridden. Initially, the cursor will be at the end of the current string. Ifspecial_operation()is called, it moves the cursor to the beginning of the string, any additional appends will be appended to the beginning of the string instead. Callingspecial_operation()again reverses the cursor operation.
- This class extends
smart_text_editorclass:- This class extends
text_editor. In this class, thespecial_operation()method is overridden to serve as an undo operation, allowing it to undo an infinite number of operations.
- This class extends
Input
[['special_text_editor'], ['write_line', 'special_operation', 'write_line'], ['World', 'Hello, ']]
Output
"Hello, World"
.
.
.
.
.
.
.
.
.
Comments