-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject1.py
454 lines (447 loc) · 18.1 KB
/
project1.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
import random
def identification():
flag = 0
while flag == 0:
print("\nWelcome to BITM sports center !")
ask = int(input("Choose to login as \n1.Admin, \n2.Student:\n3.exit\n "))
if ask == 1:
adminlogin()
elif ask == 2:
while True:
ask1 = int(input("Are you a Registered Student (0 for yes, 1 for no)? "))
if ask1 == 0:
rstudentlogin()
break
if ask1 == 1:
studentmenu()
break
else:
print("Invalid input. Please try again.")
elif ask==3:
flag = 1
break
else:
print("Invalid input. Please try again")
def adminlogin():
print("\nPlease login to access system.")
while True:
name = str(input("Username: "))
pswd = str(input("Password: "))
if (name == "deepak" and pswd == "3br22ai020") or (name == "dileep" and pswd == "3br22ai040") or (name == "bramha" and pswd == "3br22ai030") or (name == "jagan" and pswd == "3br22ai001"): #only continue if both name and pswd are correct
print("Login Successful!")
adminmenu()
break
else:
print("Username or password incorrect, please try again.")
def rstudentlogin():
print("\nPlease login to access system.")
studname = []
studid = []
f = open("Registered_Students_Records.txt", "r")
for line in f:
studid.append(line.split(",")[0])
studname.append(line.split(",")[1])
f.close()
trylogin = True
flag = 0
while flag == 0:
name = str(input("Username: "))
pswd = str(input("Your Student ID: "))
for i in studname:
if name == i:
index1 = studname.index(i)
trylogin = True
break
else:
trylogin = False
continue
for j in studid:
if pswd == j:
index2 = studid.index(j)
trylogin = True
break
else:
trylogin = False
continue
while trylogin == True:
if name == studname[index1] and pswd == studid[index2]:
print("Login Successful!")
flag = 1
rstudentmenu()
break
while trylogin == False:
print("Username or StudentID incorrect. Please try again.")
break
def studentmenu():
flag = 0
while flag == 0:
print("\nWELCOME, STUDENT.")
print("1. View details of Sport\n2. View details of Sport Schedule\n3. Register to Access Other Details\n4. Exit")
action = int(input("Please choose an action (Enter numbers 1-4):"))
if action == 1:
showsportrec()
elif action == 2:
showschedulerec()
elif action == 3:
addregstudrec()
elif action == 4:
flag = 1
else:
print("Invalid input. Please enter numbers 1-4 only.")
def rstudentmenu():
flag = 0
while flag == 0:
print("\nWELCOME, REGISTERED STUDENT!")
print("1. View Coach Record\n2. View Self Record\n3. Provide Feedback and Rating to Coach\n4. Exit")
action = int(input("Please choose an action (Enter numbers 1-6):"))
if action == 1:
showcoachrec()
elif action == 2:
showselfrec()
elif action == 3:
feedback()
elif action == 4:
flag = 1
break
else:
print("Invalid input. Please enter numbers 1-5 only.")
def adminmenu():
flag = 0
while flag == 0:
print("\nWELCOME, ADMIN!")
print("1. Add Records\n2. Display Records\n3. Attendence \n4. Exit")
action = int(input("Please choose an action (Enter numbers 1-4):"))
if action == 1:
addrec()
elif action == 2:
disrec()
elif action ==3:
attendence()
elif action==4:
flag = 1
else:
print("Invalid input. Please enter numbers 1-3 only.")
def addcoachrec():
flag = 0
f = open("Coach_Records.txt", "a")
while flag == 0:
print("\nEnter coach details:")
coach_ID = input("Enter ID: ")
name = input("Enter name: ")
date_join = input("Enter date joined (dd/mm/yyyy): ")
date_term = input("Duaration: ")
hrly_rate = input("Enter hourly rate: ")
phone = input("Enter phone number: ")
address = input("Enter address: ")
SC_code = input("Enter Sport Centre code: ")
SC_name = input("Enter Sport Centre name: ")
sport_code = input("Enter sport code: ")
sport_name = input("Enter sport name: ")
rating = input("Rating (1-5): ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input, please try again.")
f.write(coach_ID +","+ name +","+ date_join +","+ date_term +","+ hrly_rate +","+ phone +","+ address +","+ SC_code +","+ SC_name +","+ sport_code +","+ sport_name +","+ rating +"\n")
f.close()
def addsportrec():
flag = 0
f = open("Sport_Records.txt", "a")
while flag == 0:
print("\nEnter Sport details:")
sport_code = input("Enter sport code: ")
sport_name = input("Enter sport name: ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input, please try again.")
f.write(sport_code +","+ sport_name + "\n")
f.close()
def addsportschedulerec():
flag = 0
f = open("Sport_Schedule_Records.txt", "a")
while flag == 0:
print("\nEnter Sport Schedule details:")
SC_code = input("Enter Sport Centre code: ")
SC_name = input("Enter Sport Centre name: ")
sport_code = input("Enter sport code: ")
sport_name = input("Enter sport name: ")
coach_ID = input("Enter coach ID: ")
name = input("Enter coach name: ")
time_start = input("Enter start time (e.g. 12:00PM): ")
time_end = input("Enter end time (e.g. 12:00PM): ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input, please try again.")
f.write(SC_code +","+ SC_name +","+ sport_code +","+ sport_name +","+ coach_ID +","+ name +","+ time_start +","+ time_end + "\n") #Write inputs to text file
f.close()
def addregstudrec():
flag = 0
f = open("Registered_Students_Records.txt", "a")
while flag == 0:
print("\nEnter student details:")
stud_ID = random.randrange(100,10**3)
name = input("Enter student name: ")
age = input("Enter age: ")
sex = input("Enter gender (Male/Female): ")
date_join = input("Enter date joined (dd/mm/yyyy): ")
date_term = input("Duration: ")
phone = input("Enter phone number: ")
address = input("Enter address: ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input. Please try again.")
f.write(str(stud_ID) +","+ name +","+ age +","+ sex +","+ date_join +","+ date_term +","+ phone +","+ address +"\n")
f.close()
print("\nWelcome, registered student! You can now login as Registered Student at main menu (username: " + name + "; password: " + str(stud_ID)+")")
def showcoachrec():
print("{0:<10}{1:<13}{2:<15}{3:<17}{4:<15}{5:<15}{6:<15}{7:<10}{8:<30}{9:<15}{10:<15}{11:>15}".format("Coach_ID","Coach_Name","Date_Joined","Date_Terminated","Hourly_Rate","Phone_Number","Address","SC_Code","SC_Name","Sports_Code","Sports_Name","Rating"))#prints title with formatted spacing
with open("Coach_Records.txt", "r") as f:
for line in f:
Coach_ID, Coach_Name, Date_Joined, Date_Terminated, Hourly_Rate, Phone_Number, Address, SC_Code, SC_Name, Sports_Code, Sports_Name, Rating = line.split(",") #split the line using comma
print("{0:<10}{1:<13}{2:<15}{3:<17}{4:<15}{5:<15}{6:<15}{7:<10}{8:<30}{9:<15}{10:<15}{11:>15}".format(Coach_ID, Coach_Name, Date_Joined, Date_Terminated, Hourly_Rate, Phone_Number, Address, SC_Code, SC_Name, Sports_Code, Sports_Name, Rating))
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def showsportrec():
print("{0:<20}{1:<20}".format("Sports_Code","Sports_Name"))
with open("Sport_Records.txt", "r") as f:
for line in f:
Sports_Code, Sports_Name = line.split(",")
print("{0:<20}{1:<20}".format(Sports_Code, Sports_Name))
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def showregstudrec():
print("{0:<15}{1:<15}{2:<20}{3:<10}{4:<15}{5:<17}{6:<15}{7:<15}".format("Student_ID","Student_Name","Age_When_Joined","Gender","Date_Joined","Duration","Phone_Number","Address"))#prints title with formatted spacing
with open("Registered_Students_Records.txt", "r") as f:
for line in f:
Student_ID,Student_Name,Age_When_Joined,Gender,Date_Joined,Date_Terminated,Phone_Number,Address = line.split(",")
print("{0:<15}{1:<15}{2:<20}{3:<10}{4:<15}{5:<17}{6:<15}{7:<15}".format(Student_ID,Student_Name,Age_When_Joined,Gender,Date_Joined,Date_Terminated,Phone_Number,Address)) #print line with formatted spacing
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def showschedulerec():
print("{0:<10}{1:<30}{2:<15}{3:<15}{4:<10}{5:<15}{6:<15}{7:<15}".format("SC_Code","SC_Name","Sports_Code","Sports_Name","Coach_ID","Coach_Name","Start_Time", "End_Time"))#prints title with formatted spacing
with open("Sport_Schedule_Records.txt", "r") as f:
for line in f:
SC_Code, SC_Name, Sports_Code, Sports_Name, Coach_ID, Coach_Name, Start_Time, End_Time = line.split(",")
print("{0:<10}{1:<30}{2:<15}{3:<15}{4:<10}{5:<15}{6:<15}{7:<15}".format(SC_Code, SC_Name, Sports_Code, Sports_Name, Coach_ID, Coach_Name, Start_Time, End_Time)) #print line with formatted spacing
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def showregschedulerec():
print("{0:<10}{1:<30}{2:<15}{3:<15}{4:<10}{5:<15}{6:<15}{7:<15}".format("SC_Code","SC_Name","Sports_Code","Sports_Name","Coach_ID","Coach_Name","Start_Time", "End_Time"))
with open("Registered_Sport_Schedule_Records.txt", "r") as f:
for line in f:
SC_Code, SC_Name, Sports_Code, Sports_Name, Coach_ID, Coach_Name, Start_Time, End_Time = line.split(",")
print("{0:<10}{1:<30}{2:<15}{3:<15}{4:<10}{5:<15}{6:<15}{7:<15}".format(SC_Code, SC_Name, Sports_Code, Sports_Name, Coach_ID, Coach_Name, Start_Time, End_Time)) #print line with formatted spacing
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def showselfrec():
flag = 0
while flag == 0:
data = input("\nEnter your name (Search is case-sensitive): ")
with open("Registered_Students_Records.txt", "r") as f:
for line in f:
Student_ID,Student_Name,Age_When_Joined,Gender,Date_Joined,Date_Terminated,Phone_Number,Address = line.split(",")
if line.startswith(data,4):
print("{0:<15}{1:<15}{2:<20}{3:<10}{4:<15}{5:<17}{6:<15}{7:<15}".format("Student_ID","Student_Name","Age_When_Joined","Gender","Date_Joined","Date_Terminated","Phone_Number","Address")) #prints title with formatted spacing
print("{0:<15}{1:<15}{2:<20}{3:<10}{4:<15}{5:<17}{6:<15}{7:<15}".format(Student_ID,Student_Name,Age_When_Joined,Gender,Date_Joined,Date_Terminated,Phone_Number,Address)) #print line with formatted spacing
while True:
ask = int(input("\nWould you like to search again (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask == 1:
flag = 1
break
else:
print("Invalid input, please try again.")
def feedback():
flag = 0
f = open("Feedback.txt","a")
while flag == 0:
print("Feedback Details:")
name1 = input("Enter your name: ")
name2 = input("Enter coach's name: ")
fdbck = input("Feedback: ")
rate = input("Rating (1-5): ")
while True:
ask = int(input("\nWould you like to add another entry? (0 for yes, 1 for no)"))
if ask == 0:
break
elif ask ==1:
flag = 1
print("Thanks for the feedback!")
break
else:
print("Invalid input, please try again.")
f.write(name1 + "," + name2 + "," + fdbck + "," + rate +"\n")
f.close()
def addrec():
while True:
print("\nADD RECORDS MENU")
print("1. Coach\n2. Sports\n3. Sport Schedule\n4. Exit")
action = int(input("Choose item to add records of (Enter numbers 1-3) or exit (Enter number 4): "))
if action == 1:
addcoachrec()
elif action == 2:
addsportrec()
elif action == 3:
addsportschedulerec()
elif action == 4:
break
else:
print("Invalid input. Please enter numbers 1-4 only.")
def disrec():
while True:
print("\nDISPLAY RECORDS MENU")
print("1. Coach\n2. Sports\n3. Registered Students\n4. Exit")
action = int(input("Choose item to display records of (Enter numbers 1-3) or exit (Enter number 4): "))
if action == 1:
showcoachrec()
elif action == 2:
showsportrec()
elif action == 3:
showregstudrec()
elif action == 4:
break
else:
print("Invalid input. Please enter numbers 1-4 only.")
def attendence():
flag=0
while flag==0:
action=int(input("1. Mark attendence \n2. Monitor attendence \n3. Exit\n Enter your choice 1-2:"))
if action==1:
markatten()
elif action == 2:
monitoratten()
elif action==3:
flag=1
else:
print("Invalid input. Please enter numbers 1-3 only.")
def markatten():
flag=0
while flag==0:
action=int(input("1.coach\n2.student\n3.Exit\nEnter your choice 1-3:"))
if action==1:
markattecoach()
elif action == 2:
markattestudent()
elif action==3:
flag=1
else:
print("Invalid input. Please enter numbers 1-3 only.")
def monitoratten():
flag=0
while flag==0:
action=int(input("1.coach\n2.student\n3.Exit\nEnter your choice 1-3:"))
if action==1:
disattecoach()
elif action == 2:
disattestudent()
elif action==3:
flag=1
else:
print("Invalid input. Please enter numbers 1-3 only.")
def markattecoach():
flag = 0
f = open("Coach_attendence.txt", "a")
while flag == 0:
print("\nEnter coach details:")
coach_ID = input("Enter ID: ")
name = input("Enter name: ")
Attendence = input("Enter Attendence: ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input, please try again.")
f.write(coach_ID +","+ name +","+ Attendence +"\n")
f.close()
def markattestudent():
flag = 0
f = open("Student_attendence.txt", "a")
while flag == 0:
print("\nEnter Student details:")
student_ID = input("Enter ID: ")
name = input("Enter name: ")
Attendence = input("Enter Attendence: ")
while True:
ask = int(input("\nWould you like to continue (0 for yes, 1 for no)? "))
if ask == 0:
break
elif ask ==1:
flag = 1
break
else:
print("Invalid input, please try again.")
f.write(student_ID +","+ name +"," + Attendence +"\n")
f.close()
def disattecoach():
print("{0:<10}{1:<13}{2:>15}".format("Coach_ID","Coach_Name","Attendence"))
with open("Coach_attendence.txt", "r") as f:
for line in f:
Coach_ID, Coach_Name ,Attendence = line.split(",")
print("{0:<10}{1:<13}{2:>15}".format(Coach_ID, Coach_Name , Attendence))
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
def disattestudent():
print("{0:<10}{1:<13}{2:>15}".format("Student_ID","Student_Name", "Attendence"))
with open("Student_attendence.txt", "r") as f:
for line in f:
Student_ID, Student_Name, Attendence = line.split(",")
print("{0:<10}{1:<13}{2:>15}".format(Student_ID, Student_Name , Attendence))
while True:
ask = int(input("\nEnter 0 to exit: "))
if ask == 0:
break
else:
print("Invalid input, please try again.")
identification()