Advertisement
Guest User

main

a guest
Dec 6th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. from Student import Student
  2. from Admin import Admin
  3. from Course import Course
  4. class Main():
  5. def login(self, u_list):
  6. check_ID = input("Enter ID: ")
  7. check_PIN = input("Enter PIN: ")
  8. if check_ID in [lis.get_id() for lis in u_list] and check_PIN in [lis.get_pin() for lis in u_list]:
  9. print("ID and Pin verified")
  10. return u_list[[lis.get_id() for lis in u_list].index(check_ID)]
  11. else:
  12. print("ID or Pin incorrect\n")
  13. return -1
  14. def student_session(self, c_list, s_list):
  15. s1 = self.login(s_list)
  16. if s1 == -1:
  17. return -1
  18. else:
  19. opt = 4
  20. while opt != -1:
  21. if opt == 1:
  22. s1.add_course(c_list)
  23. elif opt == 2:
  24. s1.drop_course(c_list)
  25. elif opt == 3:
  26. s1.list_courses(c_list)
  27. elif opt == 0:
  28. break
  29. opt = int(input("Enter 1 to add course, 2 to drop course, 3 to see courses you have registered, 0 to exit: "))
  30. def admin_session(self, c_list, a_list):
  31. a1 = self.login(a_list)
  32. if a1 == -1:
  33. return -1
  34. else:
  35. opt = 3
  36. while opt != -1:
  37. if opt == 1:
  38. a1.show_roster(c_list)
  39. elif opt == 2:
  40. a1.change_max_size(c_list)
  41. elif opt == 0:
  42. break
  43. opt = int(input("Enter 1 to show class roster, 2 to change max class size, 0 to exit: "))
  44. def main():
  45. course_list = []
  46. student_list =[]
  47. admin_list = []
  48. init_lists(course_list, student_list, admin_list)
  49. opt = int(input("Enter 1 if you are student, 2 if you are administrator, 0 to quit: "))
  50. while opt != 0:
  51. if opt == 1:
  52. Main().student_session(course_list, student_list)
  53. elif opt == 2:
  54. r_list = Course.roster
  55. Main().admin_session(course_list, admin_list)
  56. elif opt == 0:
  57. break
  58. opt = int(input("Enter 1 if you are student, 2 if you are administrator, 0 to quit: "))
  59. def init_lists(c_list, s_list, a_list):
  60. course1 = Course("CSC121", 2)
  61. course1.add_student("1004")
  62. course1.add_student("1003")
  63. c_list.append(course1)
  64. course2 = Course("CSC122", 2)
  65. course2.add_student("1001")
  66. c_list.append(course2)
  67. course3 = Course("CSC221", 1)
  68. course3.add_student("1002")
  69. c_list.append(course3)
  70. student1 = Student("1001", "111")
  71. s_list.append(student1)
  72. student2 = Student("1002", "222")
  73. s_list.append(student2)
  74. student3 = Student("1003", "333")
  75. s_list.append(student3)
  76. student4 = Student("1004", "444")
  77. s_list.append(student4)
  78. admin1 = Admin("7001", "777")
  79. a_list.append(admin1)
  80. admin2 = Admin("8001", "888")
  81. a_list.append(admin2)
  82. Main.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement