Advertisement
Paarzivall

Untitled

Mar 11th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import datetime
  2.  
  3.  
  4. class Note(object):
  5.     Id = 0
  6.  
  7.     def __init__(self, text, tag):
  8.         Note.Id += 1
  9.         self.ID = Note.Id
  10.         self.tag = tag
  11.         self.text = text
  12.         self.data = datetime.datetime.now()
  13.  
  14.     def match(self):
  15.         if isinstance(self.__text, str) or isinstance(self.__tag, str):
  16.             return True
  17.         else:
  18.             return False
  19.  
  20.     def __str__(self):
  21.         return f"Id: {self.ID}\t\t\tData: {self.data}\n\tTag:\t\t\t{self.tag},\n\tText:\t\t\t{self.text}"
  22.  
  23.  
  24. class Notebook(Note):
  25.  
  26.     def __init__(self):
  27.         self.notes = []
  28.  
  29.     def new_note(self, ob):
  30.         self.notes.append(ob)
  31.  
  32.     def __str__(self):
  33.         return super(Notebook, self).__str__()
  34.  
  35.  
  36. def main():
  37.     notatka = Note("text", "tag")
  38.     note = Notebook()
  39.     note.new_note(notatka)
  40.     print(note)
  41.  
  42.  
  43. if __name__ == '__main__':
  44.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement