Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Phone:
- def __init__(self, model, price, cpu, display):
- self._model = model
- self._price = price
- self._cpu = cpu
- self._display = display
- class DBPhone(Phone):
- def __init__(self, model, price, cpu, display):
- super().__init__(model, price, cpu, display)
- def save_to_file(self):
- open('base', 'w').write(' '.join(map(str, [self._model, self._price, self._cpu, self._display])))
- def print_from_file(self):
- base = open('base', 'r').read().split()
- print('Model: %s\nPrice: %s\nCPU: %s\nDisplay: %s' % (base[0], base[1], base[2], base[3]))
- phone = DBPhone('Samsung', 20000, 2.4, 5.5)
- phone.save_to_file()
- phone.print_from_file()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement