-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlab2_3.py
26 lines (23 loc) · 798 Bytes
/
lab2_3.py
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
class CarStack:
def __init__(self):
self.MAX_SIZE = 4
self.stack = []
def isFull(self):
return len(self.stack) >= self.MAX_SIZE
def depart(self,car):
if car in self.stack:
self.stack.remove(car)
else:
if len(self.stack) == 0:
print('cannot depart : soi empty')
else:
print('cannot depart : not found')
def arrive(self,car):
if int(car) in range(1,self.MAX_SIZE+1) and not self.isFull():
self.stack.append(car,int(car))
print('space left',self.MAX_SIZE - len(self.stack))
else:
if self.isFull():
print('cannot arrive : soi full')
else:
print('cannot arrive : No car',car)