[email protected] pdf file shows the assignment. I completed half of it, so I need the last 4 methods done in accordance to the doc tests and pdf file specifications. I also want a different way of doing the __eq__ method of the person class. Explanations of the uncompleted parts would be useful, but are not necessary. Has to be done befor 11:59 EST,but I want it an hour earlie
CMPSC-132: Programming and Computation II Summer 2020 Homework 2 Due Date: 06/21/2020, 11:59PM EST 100 pts Read the instructions carefully before starting the assignment. Make sure your code follows the stated guidelines to ensure full credit for your work. Instructions: - The work in this assignment must be completed alone and must be your own. If you have questions about the assignment, contact the instructor or Learning Assistants instead of asking for a solution online. - Download the starter code file from the HW2 Assignment on Canvas. Do not change the function names or given started code on your script. - A doctest is provided as an example of code functionality. Getting the same result as the doctest does not guarantee full credit. You are responsible for debugging and testing your code with enough data, you can share ideas and testing code during your recitation class. As a reminder, Gradescope should not be used to debug and test code! - Each function must return the output (Do not use print in your final submission, otherwise your submissions will receive a -10 point deduction) - Do not include test code outside any function in the upload. Printing unwanted or ill- formatted data to output will cause the test cases to fail. Remove all your testing code before uploading your file (You can also remove the doctest). Do not include the input() function in your submission. - Examples of functionality are given in the starter code. - You are responsible for debugging and testing your code with enough data, you can share testing code on Piazza. Goal: The goal of this homework is to reinforce the fundamental concepts of object-oriented programming in Python. Through this homework, you should gain a better idea of how to implement a system of classes that build on each other. The main concept is to implement classes that represent a “classroom”. There are eight classes you must implement: Course, Catalog, Semester, Loan, Person, Staff, Student and StudentAccount. Each class has its own purpose which will be explained below. You will also implement a standalone function that will help transform a Person into a Student. A non-comprehensive list of concepts you should know to complete this assignment is: • Basic class syntax / creation Python (attributes, methods, definitions) • Special/Magic methods • Dictionaries • Encapsulation • Polymorphism through Operator and Method Overloading • Inheritance • Property methods • Firm understanding of what it means for Python to be an “Object-Oriented” language If you have difficulties understanding any of the concepts mentioned above after you have watched the video lectures and read the notes, don’t hesitate to ask any of the staff members for assistance before starting the assignment, we will be more than happy to help you out! Overview of Classes to Implement Note: All objects should have the __init__ method with predefined parameters, which we have given you. Do NOT modify these definitions under any circumstance. Class Course The Course class will be the simplest of the eight. It contains three attributes: cid, cname and credits. The cid represents a course id and is a string in the form similar to “CMPSC132”. The cname represents the course name and is a string that contains the title of the course, such as “Programming in Python II”. The credits parameter is an integer that represents the numbers of credits earned in the course, for example 3. Methods: 1. __str__ special method: a. You must implement the __str__ special method that returns a formatted summary of the Course information as a string in the form of Course(cid, cname, credits). For example, the previous course with cid “CMPSC132”, cname “Programming in Python II”, and credits 3 should be represented as the string “Course(CMPSC132, Programming in Python II, 3)” 2. __repr__ special method: a. Should return the same string as the __str__ method. 3. __eq__ special method: a. This method should allow for the == operator to be used to check equality between courses. This should return a boolean value that indicates whether or not two courses are the same based solely on their cid. You should perform type checking in this function. Class Catalog The Catalog class is a class that will act as a way to store a collection of Course objects. It contains one instance attribute called courseOfferings, which is a dictionary that stores Course objects, accessible by their cids. That is, the (key, value) pair would be (CourseObject.cid, CourseObject), where CourseObject is an instance of the Course class. Methods: 1. addCourse method: a. Inputs: i. cid - string representing a course id ii. cname - string representing a course name iii. credits – integer representing course credits b. You must implement the addCourse method that creates an instance of a Course object with the given cid, cname and credits inputs and stores them in the courseOfferings instance attribute in the previously specified format. If a course is already located in the courseOfferings dictionary, then you should output “Course already added”. Otherwise, add the Course instance and output “Course added successfully”. Keep in mind you should return strings instead of printing. 2. removeCourse method a. Inputs: i. cid - string representing a course id to identify the course that should be deleted b. You must implement the removeCourse method that uses the given cid to delete the associated Course from the courseOfferings dictionary. If the course is not in the dictionary, output “Course not found”. Otherwise, delete the entry in the dictionary and output “Course removed successfully”. Keep in mind you should return strings instead of printing. Class Semester The Semester class is a class that will store a collection of Course objects per semester for a student. Semesters are defined by a semester number sem_num, which is an integer. It also contains the instance attribute courses, which is list that stores Course objects that a student enrolled for a given semester. Methods: 1. __str__ special method: a. You must implement the __str__ special method that returns a formatted summary of all the courses added to a semester as a string in the form of Course(cid, cname, credits), Course(cid, cname, credits), …. If no courses have been added to the semester, the method returns ‘No courses’ 2. __repr__ special method: a. Should return the same string as the __str__ method. 3. addCourse method: a. Inputs: i. course – Course object b. This method adds the Course object into the courses attribute, but before it does it, method validates the input, returns the string ‘Invalid course’ if invalid input was provided. Keep in mind you should return strings instead of printing. 4. dropCourse method: a. Inputs: i. course – Course object b. This method removes the Course object from the courses attribute, but before it does it, method validates the input, returns the string ‘Invalid course’ if invalid input was provided or returns ‘Not such course’ if there is an attempt to drop a course that is not being taken. Keep in mind you should return strings instead of printing. 5. totalCredits method a. This method is a property method (it behaves like an attribute) that computes the total number of credits in that semester and returns the total as an integer 6. isFullTime method a. This method is a property method (it behaves like an attribute) that determines whether a student could be considered full-time (greater than or equal to 12 credits) or not, returning boolean values Class Loan The Loan class is a class that represents a determined amount of money. Loans are defined by a loan’s amount defined using numeric values. It also contains the instance attribute loan_id, which is a pseudo-random integer between 10000 and 99999. Methods: 1. __str__ special method: a. You must implement the __str__ special method that returns the current value of amount as a string with the form “Balance: $amount” 2. __repr__ special method: a. Should return the same string as the __str__ method. 3. __loanID method a. This method is a property method (it behaves like an attribute) that uses the random module to return an integer between 10000 and 99999. This value should be saved in the loan_id attribute when initializing Loan objects. Class Person A Person object is a basic representation of a person. It contains two instance attributes: name and ssn, where ssn should be a private attribute. The example person we will use for explaining the methods is the Person object that was instantiated as Person('Jason Lee', '204-99-2890'). Methods: 1. __str__ special method: a. You must implement the __str__ special method that prints a formatted summary of the Person information as a string in the form of Person(name, ***- **-xxxx). Where the ssn is displayed in a hidden format, only showing the last 4 numbers. For example, the example Person with name “Jason Lee” and ssn “204-99-2980” should be represented as the string “Person(Jason Lee, ***-**- 2980)”. 2. __repr__ special method: a. Should return the same string as the __str__ method. 3. get_ssn method: a. This method acts as a getter method in order to access the private ssn instance attribute. It should just return the ssn instance attribute (should be a string). 4. __eq__ special method: a. This special method should return True if two Person instances have the same ssn, False otherwise. Also, this method should only evaluate equality if the other object is a Person, otherwise just return False. Class Staff The Staff class inherits from the Person class. It has the same instance attributes as the Person class, but with one added private attribute, supervisor to support extended functionality. This attribute is set to None when the staff member does not have a supervisor defined. The supervisor is another Staff object. Your __init__ method must utilize the Person superclass to initialize the ssn and name ( i