Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me debug my code. It needs to pass all the doctests it is in python you can change the code if you like,

image text in transcribed Please help me debug my code. It needs to pass all the doctests it is in python you can change the code if you like, but no extra helper functions and extra imports, only import random is allowed

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

'''

CREDIT_PRICE = 1000

def __init__(self, student):

self.student = student

self.balance = 0

self.loans = {}

def __str__(self):

return f'Name: {self.student.name} ID: {self.student.id} Balance: ${self.balance}'

__repr__ = __str__

def makePayment(self, amount):

self.balance-=amount

return self.balance

def chargeAccount(self, amount):

self.balance+=amount

return self.balance

Section 5: The StudentAccount class This class represents a financial status of the student based on enrollment and is saved to a Student object as an attribute. This class should also contain an atribute that stores the price per credit, initially $1000/ credit. This cost can change at any time and should afect the future price of enrollment for ALL students. ttrih stec Methnds Snerial mathnos makePayment(self, amount) Makes a payment by subtracting amount from the balance. chargeAccount(self, amount) Adds amount towards the balance. _str__self), repr__(self) Returns a formatted summary of the loan as a string. The format to use is (spread out over three

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_2

Step: 3

blur-text-image_3

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions