forked from Chris-m41/CS241
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSweek06.py
62 lines (45 loc) · 1.32 KB
/
DSweek06.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from collections import deque
class Student:
def __init__(self):
self.name = ""
self.course = ""
def prompt(self):
self.name = input("Enter name: ")
self.course = input("Enter course: ")
def display(self):
print("Now helping {} with {}".format(self.name, self.course))
class HelpSystem:
def __init__(self):
self.waiting_list = deque()
def is_student_waiting(self):
return len(self.waiting_list) > 0
def add_to_waiting_list(self, student):
self.waiting_list.append(student)
def help_next_student(self):
if self.is_student_waiting():
student = self.waiting_list.popleft()
student.display()
print()
else:
print("\nNo one to help\n")
def main():
# s = Student()
h = HelpSystem()
selection = 0
print("Options: ")
while selection != 3:
print("1. Add a new student ")
print("2. Help next student ")
print("3. Quit")
selection = int(input("Enter selection: "))
if selection == 1:
s = Student()
print()
s.prompt()
print()
h.add_to_waiting_list(s)
elif selection == 2:
h.help_next_student()
print("\nGoodbye")
if __name__ == "__main__":
main()