-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinter.py
More file actions
42 lines (31 loc) · 1.21 KB
/
printer.py
File metadata and controls
42 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from importlib import resources
from datetime import datetime
class Printer:
def __init__(self):
self.resources = {
'paper':10,
'ink': 5
}
def report(self):
'''Prints a report of all printer resources'''
for key in self.resources:
print(f"{key}: {self.resources[key]}, tickets left")
input()
def has_enough_resources(self):
'''Returns True if ticket can be printed or return false if Paper and Ink is not sufficient.'''
for key in self.resources:
if self.resources[key] < 1:
print(f'Sorry there is not enough {key} to print ticket')
return False
return True
def print_ticket(self, station):
'''Print Ticket with From, To and Cost Detail'''
print('------------ Ticket --------------')
print("From: Katra")
print(f"To: {station.name}")
print(f"Cost: {station.cost}")
print(f"Printed: {str(datetime.now())}")
print('----------------------------------')
input()
for key in self.resources:
self.resources[key] = self.resources[key] - 1