-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp-system.py
73 lines (57 loc) · 1.92 KB
/
help-system.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
63
64
65
66
67
68
69
70
71
72
73
from collections import deque
class Student:
def __init__(self) -> None:
self.name = "Unnamed"
self.course = "Unkonown"
def prompt(self):
self.name = input("Enter name: ")
self.course = input("Enter course: ")
def display(self):
print ("Now helping {1} with {0}".format(self.course, self.name))
class HelpSystem:
def __init__(self) -> None:
#super().__init__()
self.waiting_list = deque()
def is_student_waiting(self):
if len(self.waiting_list) >= 1:
return True
else:
return False
def add_to_waiting_list(self, Student):
self.waiting_list.append(Student)
def help_next_student(self):
if self.is_student_waiting() == True:
# How can this work if display() function is not defined in this class? And there is no inheritance either
# This line prints the Student at the head of the queue using the display() method from Student() class and pop it from the deque
self.waiting_list.popleft().display()
else:
print ("No one to help")
def options_show():
print ("Options:")
print ("1. Add a new student")
print ("2. Help next student")
print ("3. Quit")
def main():
help_sys = HelpSystem()
# Variable status controls the while loop
status = True
# Option stores the selection from user
option = ""
while status:
options_show()
option = input ("Enter selection: ")
if option == "1":
print ("")
new_student = Student()
new_student.prompt()
help_sys.add_to_waiting_list(new_student)
print ("")
elif option == "2":
print ("")
help_sys.help_next_student()
print ("")
elif option == "3":
print("\nGoodbye")
status = False
if __name__ == "__main__":
main()