-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcashier-count.py
More file actions
98 lines (74 loc) · 2.03 KB
/
Copy pathcashier-count.py
File metadata and controls
98 lines (74 loc) · 2.03 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class Counter:
def __init__(self, value):
self.value = value
class Node:
def __init__ (self, data):
self.data = data
self.next = None
self.prev = None
class list:
def __init__ (self):
self.head = None
self.tail = None
self.total = 0
def push (self, value):
NewNode = Node(value)
self.total += value.value
if self.head is None:
self.head = NewNode
self.tail = NewNode
return
if (self.tail.next is None):
self.tail.next = NewNode
self.tail = NewNode
def delete (self):
node = self.head
if (node is None):
self.tail = None
return
if (self.total > 0):
self.total -= node.data.value
# remove head
if (node.prev is None):
new_node = node.next
if (new_node is not None):
new_node.prev = None
if (new_node.next is not None):
new_node.next.prev = new_node
self.head = new_node
return
counter_one = list()
counter_two = list()
counter_three = list()
def show():
print('Caixa 1: ' + str(counter_one.total))
print('Caixa 2: ' + str(counter_two.total))
print('Caixa 3: ' + str(counter_three.total))
def update_counters(counter):
if counter == 1:
counter_one.delete()
elif counter == 2:
counter_two.delete()
elif counter == 3:
counter_three.delete()
def insert_counter_one(value):
counter_one.push(Counter(value))
def insert_counter_two(value):
counter_two.push(Counter(value))
def insert_counter_three(value):
counter_three.push(Counter(value))
if __name__ == '__main__':
while True:
try:
option, quantity = input().split()
if option == 'PROXIMO':
update_counters(int(quantity))
elif option == '1':
insert_counter_one(int(quantity))
elif option == '2':
insert_counter_two(int(quantity))
elif option == '3':
insert_counter_three(int(quantity))
except:
break
show()