Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Student import Student
- from Admin import Admin
- from Course import Course
- class Main():
- def login(self, u_list):
- check_ID = input("Enter ID: ")
- check_PIN = input("Enter PIN: ")
- if check_ID in [lis.get_id() for lis in u_list] and check_PIN in [lis.get_pin() for lis in u_list]:
- print("ID and Pin verified")
- return u_list[[lis.get_id() for lis in u_list].index(check_ID)]
- else:
- print("ID or Pin incorrect\n")
- return -1
- def student_session(self, c_list, s_list):
- s1 = self.login(s_list)
- if s1 == -1:
- return -1
- else:
- opt = 4
- while opt != -1:
- if opt == 1:
- s1.add_course(c_list)
- elif opt == 2:
- s1.drop_course(c_list)
- elif opt == 3:
- s1.list_courses(c_list)
- elif opt == 0:
- break
- opt = int(input("Enter 1 to add course, 2 to drop course, 3 to see courses you have registered, 0 to exit: "))
- def admin_session(self, c_list, a_list):
- a1 = self.login(a_list)
- if a1 == -1:
- return -1
- else:
- opt = 3
- while opt != -1:
- if opt == 1:
- a1.show_roster(c_list)
- elif opt == 2:
- a1.change_max_size(c_list)
- elif opt == 0:
- break
- opt = int(input("Enter 1 to show class roster, 2 to change max class size, 0 to exit: "))
- def main():
- course_list = []
- student_list =[]
- admin_list = []
- init_lists(course_list, student_list, admin_list)
- opt = int(input("Enter 1 if you are student, 2 if you are administrator, 0 to quit: "))
- while opt != 0:
- if opt == 1:
- Main().student_session(course_list, student_list)
- elif opt == 2:
- r_list = Course.roster
- Main().admin_session(course_list, admin_list)
- elif opt == 0:
- break
- opt = int(input("Enter 1 if you are student, 2 if you are administrator, 0 to quit: "))
- def init_lists(c_list, s_list, a_list):
- course1 = Course("CSC121", 2)
- course1.add_student("1004")
- course1.add_student("1003")
- c_list.append(course1)
- course2 = Course("CSC122", 2)
- course2.add_student("1001")
- c_list.append(course2)
- course3 = Course("CSC221", 1)
- course3.add_student("1002")
- c_list.append(course3)
- student1 = Student("1001", "111")
- s_list.append(student1)
- student2 = Student("1002", "222")
- s_list.append(student2)
- student3 = Student("1003", "333")
- s_list.append(student3)
- student4 = Student("1004", "444")
- s_list.append(student4)
- admin1 = Admin("7001", "777")
- a_list.append(admin1)
- admin2 = Admin("8001", "888")
- a_list.append(admin2)
- Main.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement