Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Descrpiton In project 1 you wrote a program for class registration system. This time we are going to rewrite that program with object oriented

Project Descrpiton

In project 1 you wrote a program for class registration system. This time we are going to rewrite that program with object oriented design.This program creates a class registration system. It allows students to log in to add courses, drop courses and list courses they have registered for. There will be two classes in the object oriented design. The first one is the Course class.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Course - course. code: String - max size: Integer - roster: List + Course(c.code: String, m.size: Integer) + add student(id: String) + dror student(id: String) + get course code(): String + student in course(id): Bool The Course class has three private instance variables. The constructor takes two arguments: Sesade is course code; me size is maximum class size. Use Sesade and m.size to initialize the instance variables course, sode and max size. Initialize roster to an empty list. The addestudent method adds a student to the roster. It has one parameter: id, which is the ID of the student to be added. If the course is already full, display error message and stop. If the student is already enrolled, display error message and stop. Otherwise, add student to roster and display a message showing which student added to which course. It has no return value. The senectudent method removes a student from roster. It has one parameter: id, which is the ID of the student to be dropped. If the student is not enrolled, display error message and stop. Otherwise, remove student from roster and display a message showing which student dropped from which course. It has no return value. The display fester method sorts and displays ID of the students enrolled in this course and the enrollment count. It has no parameter and no return value The getegurse code method has no parameter and returns the value of the instance variable seurassade. The studentaithegurae method tests whether a student is enrolled in this course. It has one parameter: id, which is the ID of the student to be tested. If student is enrolled in this course, return True. Otherwise, return false. Student - id: String - pin: String + Student(id: String, pin: String) + get.ido: String + get pino: String + add.course(clist: List) + drop..course(calist: List) + list.courses(slist: List) The Student class has two protected instance variables: id and pin. The constructor takes two arguments: id and pin. Use these arguments to initialize corresponding instance variables. The getais method has no parameter and returns the value of the instance variable id. The get pin method has no parameter and returns the value of the instance variable pin. The addeurs method adds a student to a course. It has one parameter: slist, which is the list of course objects. It asks user to enter the course he/she wants to add. If the course is not offered, display error message and stop. Otherwise, call the addestudent method of the course to add the student. This method has no return value. The dresseurse method drops a student from a course. It has one parameter: solist, which is the list of course objects. It asks user to enter the course he/she wants to drop. If the course is not offered, display error message and stop. Otherwise, call the drorecstudent method of the course to drop the student. This method has no return value. The list sources method displays and counts courses a student has registered for. It has one parameter: Sadist, which is the list of course objects. It iterates over s list to display and count courses the student is in the roster. This method has no return value. You must define the following functions in the main module. Function login(id, sulist) Specification This function allows a student or an administrator to log in. It has two parameters: id and a list, which is the list of Student objects. This function asks user to enter PIN. If the ID and PIN combination matches the data in a Student object in sadist, display message of verification and return the Student object. Otherwise, display error message and return None. This function manages the whole registration system. It has no parameter. It creates student list and course list. It calls the inite dista function, which is provided, to initialize these two lists. It uses a loop to allow users to create multiple student sessions, which allows students to log in, add courses, drop courses and list courses registered. This function has no return value. main The main function is partially written for you. You must include the following code in your program without modifications. def main(): Sukasalist = [] studentetist [] inabandiste seuestste studentsattst) The main function creates two lists and calls the instaltate function. This function adds a few elements to these lists. The code of this function is provided to you. You just need to copy and paste it to your main module. def initatista (Satist, Xatist): + ------- --- # This function adds elements to counseatist and studentatist # It makes testing and grading easier. It has two parameters: # wist is the list of course objects; artist is the list of # Student objects. This function has no return value. coursel = Course ("CSC101", 3) coursel.add_student ("1004") coursel.add_student ("1003") Satist.append (coursel) course2 = Course ("CSC102", 2) course2.add_student ("1001") Satistaprend (course2) course3 = Course ("CSC103", 1) course3.add_student ("1002") Gatiskarrend (course 3) studenti = Student ("1001", "111") Satiskarrend (studenti) student2 = Student ("1002","222") Batistaprend (student2) student 3 = Student ("1003", "333") Batistaprend (student3) student 4 = Student ("1004", "444") Batistaprend (student4) The following is an example. Student 1004 added to CSC101 Student 1003 added to CSC101 Student 1001 added to CSC102 Student 1002 added to CSC103 Enter ID to log in, or 0 to quit: 1234 Enter PIN: 111 ID or PIN incorrect Enter ID to log in, or 0 to quit: 1001 Enter PIN: 111 ID and PIN verified Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 1 Enter course you want to add: CSC111 Course not found Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 1 Enter course you want to add: CSC102 You are already enrolled in this course Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 1 Enter course you want to add: CSC103 Course already full Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 1 Enter course you want t you want to add: CSC101 Student 1001 added to CSC101 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 2 Enter course you want to drop: CSC111 Course not found Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 2 Enter course you want to drop: CSC103 You are not enrolled in this course Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 3 Course registered: CSC101 CSC102 Number of courses registered: 2 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 2 Enter course you want to drop: CSC101 Student 1001 removed from CSC101 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 3 Course registered: CSC102 Number of courses registered: 1 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 0 Session ended. Enter ID to log in, or 0 to quit: 1002 Enter PIN: 222 ID and PIN verified Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 3 Course registered: CSC103 Number of courses registered: 1 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 1 Enter course you want to add: CSC101 Student 1002 added to CSC101 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 3 Course registered: CSC101 CSC103 Number of courses registered: 2 Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: 0 Session ended. Enter ID to log in, or 0 to quit: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions