Question: 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,

 Please help me debug my code. It needs to pass all 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

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!