Interview Query

Text Editor With OOP

Start Timer

0:00:00

Upvote
3
Downvote
Save question
Mark as completed
View comments (1)
Next question

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:

  1. text_editor class:

    • 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 deletes char_num number 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.
  2. moving_text_editor class:

    • This class extends text_editor. The special_operation() method is overridden. Initially, the cursor will be at the end of the current string. If special_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. Calling special_operation() again reverses the cursor operation.
  3. smart_text_editor class:

    • This class extends text_editor. In this class, the special_operation() method is overridden to serve as an undo operation, allowing it to undo an infinite number of operations.

Input

[['special_text_editor'], ['write_line', 'special_operation', 'write_line'], ['World', 'Hello, ']]

Output

"Hello, World"

.
.
.
.
.


Comments

Loading comments