Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in python This is the starter code with the doctest it needs to pass class Student(Person): ''' >>> C = Catalog() >>> C._loadCatalog(cmpsc_catalog_small.csv) >>>

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Code in python

This is the starter code with the doctest it needs to 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

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 Aath A. Cusciol mosts ad. 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 initialization. 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 semesters. 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 appropriate amount of money. 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 enrollment), 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

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago