Advertisement
emssik

Untitled

Apr 17th, 2024
460
0
12 hours
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. class TextDocument:
  2.     def __init__(self):
  3.         self.textLines = []
  4.  
  5.     def get_text_lines(self):
  6.         return self.textLines
  7.  
  8. class TextEditor:
  9.     def __init__(self):
  10.         self.currentDocument = TextDocument()
  11.  
  12.     def add_text(self, line):
  13.         self.currentDocument.textLines.append(line)
  14.  
  15.     def remove_text(self, line_index):
  16.         if line_index < len(self.currentDocument.textLines):
  17.             self.currentDocument.textLines.pop(line_index)
  18.  
  19.     def display_document(self):
  20.         for line in self.currentDocument.get_text_lines():
  21.             print(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement