CSE 1010 Lecture Notes - Lecture 22: Init, Social Security Number
CSE 1010 verified notes
22/29View all
Document Summary
Cse 1010 - introduction to computing for engineers. 2 amount = check. getamount() print( the amount is", amount) try: bal = source. withdraw(amount) self. deposit(amount) except: print( insufficient funds") We would need to copy the bankaccount class again, and paste it into a new file, then add more methods to it. Or, what if we wanted to make even more accounts, such as. They would all start with the bankaccount class. If we wanted to add these new accounts/classes, we would need to tell the. We can do this by adding a new method to the __init__ function in the. Bankaccount class, which shoud now look like this (changes are in bold class bankaccount: def __init__(self, number, name, ssn self. _number = number self. _name = name self. _balance = 0. 0 self. _ssn = ssn. But wait, we would need to add this new method to every class (account) that this person owns, which is too much work to do.