-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwaitlist_manager.py
More file actions
79 lines (54 loc) · 2.2 KB
/
Copy pathwaitlist_manager.py
File metadata and controls
79 lines (54 loc) · 2.2 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
# Create a Node class to represent each customer in the waitlist
class Node:
'''
A class representing a node in a linked list.
Attributes:
name (str): The name of the customer.
next (Node): A reference to the next node in the list.
'''
# Create a LinkedList class to manage the waitlist
class LinkedList:
'''
A class representing a linked list to manage a waitlist.
Attributes:
head (Node): The first node in the linked list.
Methods:
add_front(name): Adds a customer to the front of the waitlist.
add_end(name): Adds a customer to the end of the waitlist.
remove(name): Removes a customer from the waitlist by name.
print_list(): Prints the current waitlist.
'''
def waitlist_generator():
# Create a new linked list instance
while True:
print("\n--- Waitlist Manager ---")
print("1. Add customer to front")
print("2. Add customer to end")
print("3. Remove customer by name")
print("4. Print waitlist")
print("5. Exit")
choice = input("Choose an option (1–5): ")
if choice == "1":
name = input("Enter customer name to add to front: ")
# Call the add_front method
elif choice == "2":
name = input("Enter customer name to add to end: ")
# Call the add_end method
elif choice == "3":
name = input("Enter customer name to remove: ")
# Call the remove method
elif choice == "4":
print("Current waitlist:")
# Print out the entire linked list using the print_list method.
elif choice == "5":
print("Exiting waitlist manager.")
break
else:
print("Invalid option. Please choose 1–5.")
# Call the waitlist_generator function to start the program
'''
Design Memo: Write Your Design Memo Include a 200–300 word response in your code or in a .txt file:
- How does your list work?
- What role does the head play?
- When might a real engineer need a custom list like this?
'''