|
@@ -1,4 +1,5 @@
|
|
|
import misc_class
|
|
|
+import pickle
|
|
|
|
|
|
|
|
|
def coin_test():
|
|
@@ -26,12 +27,63 @@ def bankaccount_test():
|
|
|
|
|
|
print(str(savings))
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+def cellphone_test():
|
|
|
+ phone_list = []
|
|
|
+
|
|
|
+ for _ in range(5):
|
|
|
+ phone = misc_class.CellPhone()
|
|
|
+ phone_list.append(phone)
|
|
|
+
|
|
|
+ for item in phone_list:
|
|
|
+ print(item.get_manufact())
|
|
|
+ print(item.get_model())
|
|
|
+ print(item.get_retail_price())
|
|
|
+
|
|
|
+
|
|
|
+def cellphone_serial():
|
|
|
+ FILE_NAME = 'cellphones.dat'
|
|
|
+ file = open(FILE_NAME, 'wb')
|
|
|
+
|
|
|
+ for _ in range(5):
|
|
|
+ phone = misc_class.CellPhone()
|
|
|
+ pickle.dump(phone, file)
|
|
|
+
|
|
|
+ file.close()
|
|
|
+ print(f'Данные записаны в {FILE_NAME}')
|
|
|
+
|
|
|
+ file = open(FILE_NAME, 'rb')
|
|
|
+ end_of_file = False
|
|
|
+ while not end_of_file:
|
|
|
+ try:
|
|
|
+ phone = pickle.load(file)
|
|
|
+ print(f'Производитель: {phone.get_manufact()}')
|
|
|
+ print(f'Номер моделы: {phone.get_model()}')
|
|
|
+ print(f'Розничная цена: {phone.get_retail_price()}')
|
|
|
+ print()
|
|
|
+ except Exception as e:
|
|
|
+ end_of_file = True
|
|
|
+
|
|
|
+ file.close()
|
|
|
+
|
|
|
|
|
|
|
|
|
def main():
|
|
|
+
|
|
|
|
|
|
- bankaccount_test()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
main()
|