Question: python please! HELPER CODE: class Catalog: ''' >>> C = Catalog() >>> C.courseOfferings {} >>> C._loadCatalog(cmpsc_catalog_small.csv) >>> C.courseOfferings {'CMPSC 132': CMPSC 132(3): Programming and Computation

python please!
 
HELPER CODE: 
 
class Catalog: ''' >>> C = Catalog() >>> C.courseOfferings {} >>> C._loadCatalog("cmpsc_catalog_small.csv") >>> C.courseOfferings {'CMPSC 132': CMPSC 132(3): Programming and Computation II, 'MATH 230': MATH 230(4): Calculus and Vector Analysis, 'PHYS 213': PHYS 213(2): General Physics, 'CMPEN 270': CMPEN 270(4): Digital Design, 'CMPSC 311': CMPSC 311(3): Introduction to Systems Programming, 'CMPSC 360': CMPSC 360(3): Discrete Mathematics for Computer Science} >>> C.removeCourse('CMPSC 360') 'Course removed successfully' >>> C.courseOfferings {'CMPSC 132': CMPSC 132(3): Programming and Computation II, 'MATH 230': MATH 230(4): Calculus and Vector Analysis, 'PHYS 213': PHYS 213(2): General Physics, 'CMPEN 270': CMPEN 270(4): Digital Design, 'CMPSC 311': CMPSC 311(3): Introduction to Systems Programming} >>> isinstance(C.courseOfferings['CMPSC 132'], Course) True ''' def __init__(self): # YOUR CODE STARTS HERE pass def addCourse(self, cid, cname, credits): # YOUR CODE STARTS HERE pass def removeCourse(self, cid): # YOUR CODE STARTS HERE pass def _loadCatalog(self, file): with open(file, "r") as f: course_info = f.read() # YOUR CODE STARTS HERE class Semester: ''' >>> cmpsc131 = Course('CMPSC 131', 'Programming in Python I', 3) >>> cmpsc132 = Course('CMPSC 132', 'Programming in Python II', 3) >>> math230 = Course("MATH 230", 'Calculus', 4) >>> phys213 = Course("PHYS 213", 'General Physics', 2) >>> econ102 = Course("ECON 102", 'Intro to Economics', 3) >>> phil119 = Course("PHIL 119", 'Ethical Leadership', 3) >>> spr22 = Semester() >>> spr22 No courses >>> spr22.addCourse(cmpsc132) >>> isinstance(spr22.courses['CMPSC 132'], Course) True >>> spr22.addCourse(math230) >>> spr22 CMPSC 132; MATH 230 >>> spr22.isFullTime False >>> spr22.totalCredits 7 >>> spr22.addCourse(phys213) >>> spr22.addCourse(econ102) >>> spr22.addCourse(econ102) 'Course already added' >>> spr22.addCourse(phil119) >>> spr22.isFullTime True >>> spr22.dropCourse(phil119) >>> spr22.addCourse(Course("JAPNS 001", 'Japanese I', 4)) >>> spr22.totalCredits 16 >>> spr22.dropCourse(cmpsc131) 'No such course' >>> spr22.courses {'CMPSC 132': CMPSC 132(3): Programming in Python II, 'MATH 230': MATH 230(4): Calculus, 'PHYS 213': PHYS 213(2): General Physics, 'ECON 102': ECON 102(3): Intro to Economics, 'JAPNS 001': JAPNS 001(4): Japanese I} ''' def __init__(self): # --- YOUR CODE STARTS HERE pass def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ def addCourse(self, course): # YOUR CODE STARTS HERE pass def dropCourse(self, course): # YOUR CODE STARTS HERE pass @property def totalCredits(self): # YOUR CODE STARTS HERE pass @property def isFullTime(self): # YOUR CODE STARTS HERE pass class Loan: ''' >>> import random >>> random.seed(2) # Setting seed to a fixed value, so you can predict what numbers the random module will generate >>> first_loan = Loan(4000) >>> first_loan Balance: $4000 >>> first_loan.loan_id 17412 >>> second_loan = Loan(6000) >>> second_loan.amount 6000 >>> second_loan.loan_id 22004 >>> third_loan = Loan(1000) >>> third_loan.loan_id 21124 ''' def __init__(self, amount): # YOUR CODE STARTS HERE pass def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ @property def __getloanID(self): # YOUR CODE STARTS HERE pass class Person: ''' >>> p1 = Person('Jason Lee', '204-99-2890') >>> p2 = Person('Karen Lee', '247-01-2670') >>> p1 Person(Jason Lee, ***-**-2890) >>> p2 Person(Karen Lee, ***-**-2670) >>> p3 = Person('Karen Smith', '247-01-2670') >>> p3 Person(Karen Smith, ***-**-2670) >>> p2 == p3 True >>> p1 == p2 False ''' def __init__(self, name, ssn): # YOUR CODE STARTS HERE pass def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ def get_ssn(self): # YOUR CODE STARTS HERE pass def __eq__(self, other): # YOUR CODE STARTS HERE pass class Staff(Person): ''' >>> C = Catalog() >>> C._loadCatalog("cmpsc_catalog_small.csv") >>> s1 = Staff('Jane Doe', '214-49-2890') >>> s1.getSupervisor >>> s2 = Staff('John Doe', '614-49-6590', s1) >>> s2.getSupervisor Staff(Jane Doe, 905jd2890) >>> s1 == s2 False >>> s2.id '905jd6590' >>> p = Person('Jason Smith', '221-11-2629') >>> st1 = s1.createStudent(p) >>> isinstance(st1, Student) True >>> s2.applyHold(st1) 'Completed!' >>> st1.registerSemester() 'Unsuccessful operation' >>> s2.removeHold(st1) 'Completed!' >>> st1.registerSemester() >>> st1.enrollCourse('CMPSC 132', C) 'Course added successfully' >>> st1.semesters {1: CMPSC 132} >>> s1.applyHold(st1) 'Completed!' >>> st1.enrollCourse('CMPSC 360', C) 'Unsuccessful operation' >>> st1.semesters {1: CMPSC 132} ''' def __init__(self, name, ssn, supervisor=None): # YOUR CODE STARTS HERE pass def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ @property def id(self): # YOUR CODE STARTS HERE pass @property def getSupervisor(self): # YOUR CODE STARTS HERE pass def setSupervisor(self, new_supervisor): # YOUR CODE STARTS HERE pass def applyHold(self, student): # YOUR CODE STARTS HERE pass def removeHold(self, student): # YOUR CODE STARTS HERE pass def unenrollStudent(self, student): # YOUR CODE STARTS HERE pass def createStudent(self, person): # YOUR CODE STARTS HERE pass class Student(Person): ''' >>> C = Catalog() >>> C._loadCatalog("cmpsc_catalog_small.csv") >>> s1 = Student('Jason Lee', '204-99-2890', 'Freshman') >>> s1 Student(Jason Lee, jl2890, Freshman) >>> s2 = Student('Karen Lee', '247-01-2670', 'Freshman') >>> s2 Student(Karen Lee, kl2670, Freshman) >>> s1 == s2 False >>> s1.id 'jl2890' >>> s2.id 'kl2670' >>> s1.registerSemester() >>> s1.enrollCourse('CMPSC 132', C) 'Course added successfully' >>> s1.semesters {1: CMPSC 132} >>> s1.enrollCourse('CMPSC 360', C) 'Course added successfully' >>> s1.enrollCourse('CMPSC 465', C) 'Course not found' >>> s1.semesters {1: CMPSC 132; CMPSC 360} >>> s2.semesters {} >>> s1.enrollCourse('CMPSC 132', C) 'Course already enrolled' >>> s1.dropCourse('CMPSC 360') 'Course dropped successfully' >>> s1.dropCourse('CMPSC 360') 'Course not found' >>> s1.semesters {1: CMPSC 132} >>> s1.registerSemester() >>> s1.semesters {1: CMPSC 132, 2: No courses} >>> s1.enrollCourse('CMPSC 360', C) 'Course added successfully' >>> s1.semesters {1: CMPSC 132, 2: CMPSC 360} >>> s1.registerSemester() >>> s1.semesters {1: CMPSC 132, 2: CMPSC 360, 3: No courses} >>> s1 Student(Jason Lee, jl2890, Sophomore) >>> s1.classCode 'Sophomore' ''' def __init__(self, name, ssn, year): random.seed(1) # YOUR CODE STARTS HERE def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ def __createStudentAccount(self): # YOUR CODE STARTS HERE pass @property def id(self): # YOUR CODE STARTS HERE pass def registerSemester(self): # YOUR CODE STARTS HERE pass def enrollCourse(self, cid, catalog): # YOUR CODE STARTS HERE pass def dropCourse(self, cid): # YOUR CODE STARTS HERE pass def getLoan(self, amount): # YOUR CODE STARTS HERE pass class StudentAccount: ''' >>> C = Catalog() >>> C._loadCatalog("cmpsc_catalog_small.csv") >>> s1 = Student('Jason Lee', '204-99-2890', 'Freshman') >>> s1.registerSemester() >>> s1.enrollCourse('CMPSC 132', C) 'Course added successfully' >>> s1.account.balance 3000 >>> s1.enrollCourse('CMPSC 360', C) 'Course added successfully' >>> s1.account.balance 6000 >>> s1.enrollCourse('MATH 230', C) 'Course added successfully' >>> s1.enrollCourse('PHYS 213', C) 'Course added successfully' >>> print(s1.account) Name: Jason Lee ID: jl2890 Balance: $12000 >>> s1.account.chargeAccount(100) 12100 >>> s1.account.balance 12100 >>> s1.account.makePayment(200) 11900 >>> s1.getLoan(4000) >>> s1.account.balance 7900 >>> s1.getLoan(8000) >>> s1.account.balance -100 >>> s1.enrollCourse('CMPEN 270', C) 'Course added successfully' >>> s1.account.balance 3900 >>> s1.dropCourse('CMPEN 270') 'Course dropped successfully' >>> s1.account.balance 1900.0 >>> s1.account.loans {27611: Balance: $4000, 84606: Balance: $8000} >>> StudentAccount.CREDIT_PRICE = 1500 >>> s2 = Student('Thomas Wang', '123-45-6789', 'Freshman') >>> s2.registerSemester() >>> s2.enrollCourse('CMPSC 132', C) 'Course added successfully' >>> s2.account.balance 4500 >>> s1.enrollCourse('CMPEN 270', C) 'Course added successfully' >>> s1.account.balance 7900.0 ''' def __init__(self, student): # YOUR CODE STARTS HERE pass def __str__(self): # YOUR CODE STARTS HERE pass __repr__ = __str__ def makePayment(self, amount): # YOUR CODE STARTS HERE pass def chargeAccount(self, amount): # YOUR CODE STARTS HERE pass def run_tests(): import doctest # Run tests in all docstrings doctest.testmod(verbose=True) # Run tests per function - Uncomment the next line to run doctest by function. Replace Course with the name of the function you want to test #doctest.run_docstring_examples(Course, globals(), name='HW2',verbose=True) if __name__ == "__main__":
 python please! HELPER CODE: class Catalog: ''' >>> C = Catalog()
>>> C.courseOfferings {} >>> C._loadCatalog("cmpsc_catalog_small.csv") >>> C.courseOfferings {'CMPSC 132': CMPSC 132(3): Programming
and Computation II, 'MATH 230': MATH 230(4): Calculus and Vector Analysis, 'PHYS
213': PHYS 213(2): General Physics, 'CMPEN 270': CMPEN 270(4): Digital Design, 'CMPSC
311': CMPSC 311(3): Introduction to Systems Programming, 'CMPSC 360': CMPSC 360(3): Discrete
Mathematics for Computer Science} >>> C.removeCourse('CMPSC 360') 'Course removed successfully' >>> C.courseOfferings
{'CMPSC 132': CMPSC 132(3): Programming and Computation II, 'MATH 230': MATH 230(4):
Calculus and Vector Analysis, 'PHYS 213': PHYS 213(2): General Physics, 'CMPEN 270':
CMPEN 270(4): Digital Design, 'CMPSC 311': CMPSC 311(3): Introduction to Systems Programming}
>>> isinstance(C.courseOfferings['CMPSC 132'], Course) True ''' def __init__(self): # YOUR CODE STARTS
HERE pass def addCourse(self, cid, cname, credits): # YOUR CODE STARTS HERE

Section 2: The Catalog class Stores a collection of Course objects in a dictionary, hy is the cid of the course, and value is the Course object that corrsponds to the same cid. addCourse(self, cld, cname, credits) Creates a Course object with the punametes and stores it as a valbe in ceuneotferiergs. removeCourse(self, cid]) loadCatalog(self, file) Reads a Consma Separated Values (cw) file with coune infurmutioe and alds its Course object to the courseOferings dictionary. We are not using any libericis so ncad and process the ove file, insicad, yoe will use string methods wo clean the string for probesing ef the cournes. The codle for reading the file has been provided in the staner code add yoe shold not modify it. The iaformation that needs to be processed is in the string course_info, Given the empse_catalog_small esv file with the following information (where you can asseme the course same does not contais any commask. capsc t32, Programing and Copptation It, 3 ment 230 , Calculu and vector healysts, 4 Mars 213,Geneeal Mysics, 2 GPpe 27e,0lgital beiles, 4 copsC 311 , Introduction te Systens Frecrumine, 3 cosse 366,01 screte mathenarics for compotur selence, 3 The eode provided to open, tead and close the file sets coerse info ards as fotlows: file " "comsc_catalog_small.csv" with open(file, " r2) as fr Given the cmpse_catalog_small.esv file with the following information (where you can assume the course name does not contain any commas): CMPSC 132, Programming and Computation II, 3 MATH 230, Calculus and Vector Analysis,4 PHYS 213, General Physics, 2 CNPEN 27e, Digital Design, 4 CMPSC 311, Introduction to Systems Progranming, 3 CMPSC 360, Discrete Mathematics for Computer Science, 3 The code provided to open, read and close the file sets course_info works as follows: file = "cmpsc_catalog_small.csv" 3> with open(file, "r") as f : ... course_info =fread() \$> course_info 'CMPSC 132, Programming and Conputation II,3 MATH 23e, Calculus and vector 311 , Introduction to Systems Programming, 3 CMPSC360,0iscrete Mathematics for Computer Science, 3 All string methods are allowed in this method, however, splitO is the most helpful to process the string as needed. Section 3: The Semester class Stores a collection of Course objects for a semester for a student. addCourse(self, course) Adde a Conuree to tha enurses diectionary dropCourse(self, course) Removes a course from this semester. totalCredits(self) A property method (behaves like an attribute) for the total number of credits in this semester. totalCredits(self) isfullTime(self) be considered full-time (tuking 12 er more dedib) or not _ir_(self._repr_(wen) Returns a formatiod sammary of the all the coerses in this semeser. Use the format: eid, ridi cid, .... Settion 4: The L.ean class A class that repesents an amoum of maney, identified by a pecubonodon number. Section 4: The Loan class A class that represents an amount of money, identified by a pseudo-random number. \[ \__{\text {str__ (self), ___repr_(self) }} \] Returns a formatted summary of the loan as a string. Use the format: Balance: Samount \begin{tabular}{|l|l|} \hline Output \\ \hline str & Formatted summary of the loan. \\ \hline \end{tabular} getloanID(self) A property method (behaves like an attribute) that pseudo-randomly generates loan ids. Use the Eindom module to return a number between 10,000 and 99,999 . The retumed value should be saved to loan_id when initializing Loan objects. randint and randrange could be helpful here! Section 6: The Person class This class is a basic representation of a person, storing name and social security number. get_ssn(self) Getter method for aceessing the private social security number attribute. _str__(self),__repr__(self) Returns a formatted summary of the person as a string. The format to use is: Personf name. _eq_(self, other) Determines if two objects are equal. For instances of this class, we will define equality when the SSN of one object is the same as SSN of the other object. You can assume at least one of the objects is a Person object. Section 7: The Staff class This class inherits from the Person class but adds extended functionality for staff members. Attributes, methods, and special methods inherited from Person are not listed in this section. id(self) Property method (behaves like an attribute) for generating staff's id. The format should be: 905 +ininials+last four numbers of ssn. (e.g. 905abc6789). Ignore the security flaws this generation method presents and assume ids are unique. applyHold(self, student) Applies a hold on a student object (set the student's hold attribute to True), removeHold(self, student) Removes a hold on a student object (set the student's hold attribute to False). unenrollStudent(self, student) Unenrolls a student object (set the student's active attribute to False). createStudent(self, person) Creates a Student object from a Person object. The new student should have the same information (namo ten) ac the nersan and alwave starte ant ac a froshman (-Finechman') Section 8: The Student class This class inherits from the Person class and is heavy extended for additional functionality. Attributes, methods, and special methods inherited from Person are not listed in this section. The implementation of Course, Catalog, Semester, Loan and StudentAccount is needed for complete functionality for instances of this class, and you are expected to use methods from some of those classes in this section. This class works in conjunction with other classes, CORRECT FUNCTIONALITY OF THIS CLASS IS WORTH 30% OF YOUR HW GRADE id(self) Property method (behaves like an attribute) for generating student's id. The format should be: initials +last four numbers of ssn (e.g.: abc6789). Ignore the security flaws this generation method presents and assume ids are unique. _ createStudentAccount(self) Creates a StudentAccount object. This should be saved in the account attribute during registerSemester(self) Creates a Semester object and adds it as a value to the semesters dictionary if the student is active and has no holds with key starting at 1 (next key is defined as max(key_value) +1 ), It also updates the student's year attribute according to the number of semesters enrolled. 'Freshman' is a firstyear student (semesters 1 and 2), 'Sophomore' is a second-year student (semesters 3 and 4). 'Junior' is a third-year student (semesters 5 and 6 ) and 'Senior' for any enrollment with more than 6 cemactane enrollCourse(self, cid, catalog) Finds a Course object with the given id from the catalog and adds it to the courses attribute of the Semester object associated with the largest key in the semesters dictionary. Charge the student's account the aporooriate amount of monev. dropCourse(self, cid) Finds a Course object with the given id from the semester associated with the largest key in the semesters dictionary and removes it. When a course is dropped, only half the course cost is refunded to the student's account (cost is based on the current credit price). getLoan(self, amount) If the student is active and currently enrolled full-time (consider the item with the largest key in the semesters dictionary the current enroliment), it creates a Loan object for the student with the given amount, adds it to the student's account's loans dictionary, and uses the amount to make a payment in the student's account. Do NOT remove the line random. seed (1) from the constructor. This ensures replicable pseudo-random number generation across multiple executions, so your loan ids should match the doctest samples. __str_(self),_repr__(self) Returns a formatted summary of the student member as a string. The format to use is: Student(name, id, year)

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 Databases Questions!