Advertisement
Guest User

Untitled

a guest
May 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. class Phone:
  2.  
  3.     def __init__(self, model, price, cpu, display):
  4.         self._model = model
  5.         self._price = price
  6.         self._cpu = cpu
  7.         self._display = display
  8.  
  9. class DBPhone(Phone):
  10.  
  11.     def __init__(self, model, price, cpu, display):
  12.         super().__init__(model, price, cpu, display)
  13.  
  14.     def save_to_file(self):
  15.         open('base', 'w').write(' '.join(map(str, [self._model, self._price, self._cpu, self._display])))
  16.  
  17.     def print_from_file(self):
  18.         base = open('base', 'r').read().split()
  19.         print('Model: %s\nPrice: %s\nCPU: %s\nDisplay: %s' % (base[0], base[1], base[2], base[3]))
  20.  
  21.  
  22.  
  23. phone = DBPhone('Samsung', 20000, 2.4, 5.5)
  24. phone.save_to_file()
  25. phone.print_from_file()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement