Question: Please take the time read this thank you Objectives Review classes and OOP Review inheritance and polymorphism Review overriding superclass method(s) in subclasses Problem Specification

Please take the time read this thank you

Objectives

  • Review classes and OOP
  • Review inheritance and polymorphism
  • Review overriding superclass method(s) in subclasses

Problem Specification

This project uses a class inheritance to implement an application that determines if students can sign up for a course based upon previous courses taken and grades earned. The program will read in from a file named grades a list of courses a student has taken and may want to take. The student is able to query the list of courses to determine if he/she may take the course, what grade was earned (if any) and what the prerequisites of the course are. Your task is to implement this program.

There are several classes in this program. Your task will be to complete a class controller, and to put as much common code from the Undergraduate and Graduate classes into the Course class (all these classes are provided). Use the class inheritance design methodologies that we have discussed in class to design your project. You will change four classes: Controller and (Course, Undergraduate, and Graduate (in cources.py). DO NOT CHANGE THE MAIN METHOD.

Input

Your program will read from a file calledgrades.txtlocated in the folder in which the program will be run. The input will contain any number of course "records". Each record has the following format.

  1. The first line of the record will indicate that the course is either "undergraduate", "graduate" or that the input is "done".
  2. The next line contains the course number, e.g. CS1120.
  3. The next line contains the course name, e.g. Computer Science II.
  4. The next line contains three integers, the number of recitation hours, lecture hours and lab hours for the course. If the course is a graduate course, then there may be the word "seminar" at the end of the input to indicate that the course has a seminar format. If the word is absent, then the course is not a seminar.
  5. The next line contains the grade earned by the student. If the student has not taken the course, the word "none" will appear for the grade.
  6. The final line of input for a record will contain a list of course numbers that are prerequisites for this course. Note that any course in this list is guaranteed to have already appeared in the input file. If there are no prerequisites, then the word "none" will appear

Example Grades.txt

Below is an example of whatgrades.txtby contain:

undergraduate CS1110 Computer Science I 2 4 0 BA none undergraduate CS1120 Computer Science II 2 4 0 none CS1110 undergraduate CS3310 Data and File Structures 1 3 0 none CS1310, CS1120 undergraduate CS1310 Foundations of Computer Sci 1 4 0 C none graduate CS5091 Computer Science Seminar 1 2 0 seminar none CS3310 done 

Processing Requirements

The application should exhibit the following functionality (see the sample output below):

  • Read the contents of the input file.
  • The file name should be hardcoded in the application.
  • Allow the user to choose from a menu of 3 options:
  • Display courses
  • Display the list of courses in ascending order (sort by the course no.);
  • Sign up courses
  • Ask the user for the course number, and then find the matching course.
  • If the course is available:
  • Allow the user to choose from a menu of 4 options:
  • If the 'get grade' option is selected, you must display the grade.
  • If the 'can take?' option is selected, you must displayyesin result if the student meets the prerequisite requirements with acceptable grades; otherwise displayno.
  • If the 'show prereqs' option is selected, you must display the list of the prerequisites in ascending order in thegetPrereqs()methods in the Undergraduate and Graduate classes. When displaying a course, use the full name as provided in thegetCourseString()method in the Undergraduate and Graduate classes.
  • If the 'sign-up quit' option is selected, you must exit Sign up courses option.
  • If the course is not available, do not allow the user to sign up; display a message indicating it is not available.
  • Display the 'Sign up courses' menu again to the user.
  • Quit
  • Exit the application and displayGood bye!
  • Allow the user to continue making requests (selecting options) until s/he selects the Quit option.

Design Requirements

Your applicationMUSTmake use of a proper inheritance relationship. It should have a superclass representing a general course level, Course, and subclasses representing the specific level of courses included (Undergraduate and graduate).

There is also a Controller class which is used by themain()method to run the program.

The code for themain()method is provided and should not be modified. This serves as the test class for your program.

NOTE:Any fields or methods common to the subclasses should be defined in the superclass. Specific functionality, such as additional data members or overriding methods, should be defined in the appropriate subclass(es).

Hints

  1. When reading from the input file, it may be helpful to strip the newline character from each line of input. Also, to "process" the comma-separated data in the input file, you can split each line read from the file, using the comma as the delimiter.
  2. Recall that the three steps used for working with input files are: open file, read data, close file.

Additional Requirements

Coding Standards

You must adhere to all conventions applicable to writing programs. This includes the use of white spaces and indentations for readability, the use of comments to explain the meaning of various methods and attributes, and the conventions for naming classes, variables, method parameters and methods.

Assignment Submission

  • Develop and submit your project on Codio.

NOTE:The penalty for late submissions as stated in the course syllabus will be applied in grading any assignment submitted late.

Example Interaction: Output should look like

------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 1 CS 1110 Computer Science I (2, 4, 0) CS 1120 Computer Science II (2, 4, 0) CS 1310 Foundations of Computer Sci (1, 4, 0) CS 3310 Data and File Structures (1, 3, 0) CS 5091 Computer Science Seminar (1, 2) Seminar ------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 2 Enter the course number: 5710 The course is not available Enter the course number: 1120 ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 1 Your grade = BA ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 3 CS 1110 Computer Science I (2, 4, 0) ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 2 yes ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 4 ------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 2 Enter the course number: 5091 ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 1 none ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 3 CS 3310 Data and File Structures (1, 3, 0) ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 2 no ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 4 ------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 2 Enter the course number: 1110 ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 2 no ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 4 ------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 2 Enter the course number: 3310 ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 3 CS 1120 Computer Science II (2, 4, 0) CS 1310 Foundations of Computer Sci (1, 4, 0) ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 2 No ------------- Sign up Menu ------------- 1) Get grade 2) Can take? 3) Show prereqs 4) Sign-up quit ---------------------------------------------- Please choose an option: 4 ------------- Main Menu ------------- 1) Display courses 2) Sign up courses 3) Quit ------------------------------------------ Please choose an option: 3 Good Bye! 

These are the ,py files/.txt files I have

main.py- do not need to change

import control as c def main(): control = c.Controller() control.read_input("grade.txt") response = "" quit_flag = False while quit_flag == False: control.show_menu() response = input("Please choose an option: ") if response == "1": control.display_courses() elif response == "2": control.sign_up_courses() elif response == "3": quit_flag = True else: print("Invalid response!") print("Good bye!") main() 

control.py- need to implement(below)

import courses class Controller: # Initializer method: - creates the required data attributes to run the project. def __init__(self): raise NotImplementedError("Controller.__init__()") # Displays the main menu options to the user. def show_menu(self): raise NotImplementedError("Controller.show_menu()") # Displays all the courses in ascending order on the screen def display_courses(self): raise NotImplementedError("Controller.display_courses()") # Searches in both the array of graduate and the array of undergraduate # for the course with the course number received as a parameter. # @parameter courseNum - The course number requested by the user (of type "string") # @return - The requested course (if found) def find_item(self, courseNum): raise NotImplementedError("Controller.find_item()") # Requests for the course number from the user, uses the findItem() # Displays the sign up menu options to the user. # Displays the grades # Displays the decision whether the user can take the course or not # Displays the prereqes def sign_up_courses(self): raise NotImplementedError("Controller.sign_up_courses()") # Reads data from the input file and stores the items in the # appropriate array. # @parameter filename - The name of the input file (of type "string") def read_input(self, filename): raise NotImplementedError("Controller.read_input()") 

courses.py - need to implement(below)

 def __init__(self): raise NotImplementedError("Course.__init__()") class Undergraduate(Course): # Initializer method - Updates the Undergraduate class's attributes. # @ param dept the two-letter department code for the course # @ param num the course number # @ param name the full course name # @ param rec the number of recitation hours # @ param lec the number of lecture hours # @ param lab the number of lab hours # @ param grade the student's grade in the course # @ param prereqs the courses that are prerequisites for this course def __init__(self, num, name, rec, lec, lab, grade, prereqs): self.number = num self.name = name self.recitationHours = rec self.lectureHours = lec self.labHours = lab self.grade = grade self.prereqs = prereqs # Determine if a student has taken the course # @ return true if there is a grade for the course def hasTaken(self): return self.grade != 'none' # Determine if a student has passed the course # @ return true if the grade is not an F def hasPassed(self): return (self.grade != 'none') and (not(self.grade < 70)) # Get the prerequisites for a course # @ return a list of Undergraduate courses def getPrereqs(self): return self.prereqs # Get the course number # @ return the course number def getCourseNumber(self): return self.number # Return the full name of the course # @ return the name of the course def getCourseName(self): return self.name # Get the number of recitation hours for the course # @ return the recitation hours def getRecitationHours(self): return self.recitationHours # Get the number of lecture hours for the course # @ return the lecture hours def getLectureHours(self): return self.lectureHours # Get the number of lab hours for the course # @ return the lab hours def getLabHours(self): return self.labHours # Get the grade the student has earned # @ return the grade def getGrade(self): return self.grade # Get a complete listing for this course name # @ return a String contain course department, number, name, lecture hours, recitation hours, and lab hours def getCourseString(self): return f"CS {self.number}: {self.name} ({self.lectureHours}, {self.recitationHours}, {self.labHours})" class Graduate(Course): # Initializer method - Updates the Graduate class's attributes. # @ param dept the two-letter department code for the course # @ param num the course number # @ param name the full course name # @ param rec the number of recitation hours # @ param lec the number of lecture hours # @ param grade the student's grade in the course # @ param prereqs the courses that are prerequisites for this course # @param seminar is course a seminar def __init__(self,num, name, rec, lec,grade, prereqs, seminar): self.number = num self.name = name self.recitationHours = rec self.lectureHours = lec self.grade = grade self.prereqs = prereqs self.isSeminar = seminar # Set the grade earned by the student for this course # @ param grade the grade earned def setGrade(self, grade): self.grade = grade # Determine if a student has taken the course # @ return true if there is a grade for the course def hasTaken(self): return self.grade != 'none' # Determine if a student has passed the course # @ return true if the grade is not an F def hasPassed(self): return (self.grade != 'none') and (not(self.grade < 80)) # Get the prerequisites for a course # @ return a list of Undergraduate courses def getPrereqs(self): return self.prereqs # Get the course number # @ return the course number def getCourseNumber(self): return self.number # Return the full name of the course # @ return the name of the course def getCourseName(self): return self.name # Get the number of recitation hours for the course # @ return the recitation hours def getRecitationHours(self): return self.recitationHours # Determine if course is a seminar # @ return true if course uses a seminar format def isASeminar(self): return self.isSeminar # Get the grade the student has earned # @ return the grade def getGrade(self): return self.grade # Get a complete listing for this course name # @ return a String contain course department, number, name, lecture hours, recitation hours, and Seminar format(if any) def getCourseString(self): cstr = f"CS {self.number}: {self.name} ({self.lectureHours}, {self.recitationHours})" if self.isSeminar: return cstr + "Seminar" else: return cstr 

input.txt and grades.txt above

1 2 5710 1120 1 3 2 4 2 5091 1 3 2 4 2 1110 2 4 2 3310 3 2 4 3 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!