-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDormSphere Using python
More file actions
67 lines (51 loc) · 1.17 KB
/
Copy pathDormSphere Using python
File metadata and controls
67 lines (51 loc) · 1.17 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
class DormSphere:
def __init__(self):
self.rooms = {
101: None,
102: None,
103: None,
104: None
}
def view_rooms(self):
print("\nRoom Details")
for room, student in self.rooms.items():
print(
room,
":",
student if student else "Available"
)
def allocate_room(self):
name = input("Student name: ")
for room in self.rooms:
if self.rooms[room] is None:
self.rooms[room] = name
print("Room allocated:", room)
return
print("No rooms available")
def remove_student(self):
name = input("Student name: ")
for room in self.rooms:
if self.rooms[room] == name:
self.rooms[room] = None
print("Student removed")
return
print("Student not found")
hostel = DormSphere()
while True:
print("""
1. View Rooms
2. Allocate Room
3. Remove Student
4. Exit
""")
choice = input("Choice: ")
if choice == "1":
hostel.view_rooms()
elif choice == "2":
hostel.allocate_room()
elif choice == "3":
hostel.remove_student()
elif choice == "4":
break
else:
print("Invalid option")