CSE 1010 Lecture Notes - Lecture 22: Init, Social Security Number

99 views3 pages
Verified Note

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents