-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.py
40 lines (27 loc) · 883 Bytes
/
classes.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# class point():
# def __init__(self, input1, input2):
# self.x = input1
# self.y = input2
# p = point(2, 8)
# print(p.x)
# print(p.y)
class Flight():
def __init__(self, capacity):
self.capacity = capacity
self.passengers = []
def add_passenger(self, name):
if not self.open_seats():
return False
self.passengers.append(name)
return True
def open_seats(self):
return self.capacity - len(self.passengers)
flight = Flight(3)
people =["Harry", "Ron", "Hermione", "Ginny"]
for person in people:
# success = flight.add_passenger(person)
# if success:
if flight.add_passenger(person):
print(f"Added {person} to flight successfully.")
else:
print(f"No available seats for {person}")