CSE 1010 Lecture Notes - Lecture 19: Init

37 views3 pages
Verified Note

Document Summary

Cse 1010 - introduction to computing for engineers. Add the withdraw method inside the bankaccount class: def withdraw(self, amount): if self. balance >= amount: else: Run it: self. balance -= amount print(cid:383)(cid:359)insufficient funds(cid:360)(cid:384) This is just like the bankaccount class that we made before. This will have all the methods and member variables of the bankaccount class, but will have an additional class and methods for writing checks. There needs to be a method to write a check (check is the new class!) We need to consider who the check is for, who it"s from, and how much it"s for. Inside the checkingaccount class: def __init__(self, number, name): self. _number = number self. _name = name self. _balance = 0. 2 self. _bank = none #need to figure this out later. Naming member variables with a leading underscore is a naming convention that should be followed (but isn"t necessary) You can use the underscore as if it were any other letter, such as: number_of_iterations abc_xyz.

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