Skip to content

Commit a6fed2d

Browse files
committed
still working
1 parent e1088f4 commit a6fed2d

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

code/Andy/python/andy_lab10_atm_v1.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,41 @@
1-
class Atm:
2-
def __init__(self, balance, intrest_rate):
3-
self.bal= 0
4-
self.balance = balance
5-
self.intrest_rate= intrest_rate
1+
class ATM:
2+
def __init__(self, balance_arg = 0, intrest_rate_arg = .001): #positional arguments. a method. a more flexable way to do it
3+
self.balance = balance_arg #balance_arg are local varable
4+
self.intrest_rate = intrest_rate_arg
65

7-
def check_balance():
6+
# def __init__(self): #positional arguments. a method
7+
# self.balance = 0 one way to do it
8+
# self.intrest_rate = .001
89

10+
def check_balance(self): # going into self to retrieve balance from what you have
11+
return self.balance #Returning is used to return a value from a function and exit the function. To return a value from a function, use the return keyword. and print means display a value dont think it'll exit the function
12+
13+
def deposit(self, amount):
14+
self.balance += amount
915

1016

1117

18+
# atm = ATM(5, .001) #putting the values for the initializer.its an object
19+
# # print("atm bal: ", atm.balance) #just for testing but not done in real life
20+
# # print('atm rate: ', atm.intrest_rate)#just for testing but not done in real life
1221

22+
# atm.check_balance() #atm is object and checkbalance is the method access the balance
23+
# # print('calling check_balance method: ', atm.check_balance())
24+
# the_balance = atm.check_balance()
1325

1426

15-
# atm = ATM() # create an instance of our class
16-
# print('Welcome to the ATM')
17-
# while True:
18-
# command = input('Enter a command: ')
19-
# if command == 'balance':
20-
# balance = atm.check_balance() # call the check_balance() method
21-
# print(f'Your balance is ${balance}')
22-
# elif command == 'deposit':
23-
# amount = float(input('How much would you like to deposit? '))
24-
# atm.deposit(amount) # call the deposit(amount) method
25-
# print(f'Deposited ${amount}')
27+
28+
atm = ATM() # create an instance of our class case sensative make the same as the class being called
29+
print('Welcome to the ATM')
30+
while True:
31+
command = input('Enter a command: ')
32+
if command == 'balance':
33+
balance = atm.check_balance() # call the check_balance() method
34+
print(f'Your balance is ${balance}')
35+
elif command == 'deposit':
36+
amount = float(input('How much would you like to deposit? '))
37+
atm.deposit(amount) # call the deposit(amount) method
38+
print(f'Deposited ${amount}')
2639
# elif command == 'withdraw':
2740
# amount = float(input('How much would you like '))
2841
# if atm.check_withdrawal(amount): # call the check_withdrawal(amount) method

code/Andy/python/sample.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# f = open('sample.txt')
2+
# contents = f.read()
3+
# print(contents)
4+
5+
f = open('sample.txt')
6+
contents = f.read()
7+
print(contents)
8+
f.close()

code/Andy/python/sample.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

0 commit comments

Comments
 (0)