CSE 1010 Lecture Notes - Lecture 19: Init
CSE 1010 verified notes
19/29View all
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.