Need help on a project To :"Create a class called BankAccount with the following parameters "

saisurya.ssa at gmail.com saisurya.ssa at gmail.com
Fri May 12 22:21:56 EDT 2017


On Saturday, December 12, 2015 at 2:35:29 PM UTC+5:30, Harbey Leke wrote:
> Create a class called BankAccount
> 
> .Create a constructor that takes in an integer and assigns this to a `balance` property.
> 
> .Create a method called `deposit` that takes in cash deposit amount and updates the balance accordingly.
> 
> .Create a method called `withdraw` that takes in cash withdrawal amount and updates the balance accordingly. if amount is greater than balance return `"invalid transaction"`
> 

> .Create a subclass MinimumBalanceAccount of the BankAccount class
> 
> Please i need help on this i am a beginer into python programming.
> 
> 
> Also below is a test case given for this project 
> 
> 
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
>   def setUp(self):
>     self.my_account = BankAccount(90)
>     
>   def test_balance(self):
>     self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
>     
>   def test_deposit(self):
>     self.my_account.deposit(90)
>     self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate')
>     
>   def test_withdraw(self):
>     self.my_account.withdraw(40)
>     self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate')
>     
>   def test_invalid_operation(self):
>     self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction')
>   
>   def test_sub_class(self):
>     self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount')

hi guys can get a perfect code and i have this code 
import time


menu_list = ["O -open account"] 
menu_list =["l - load details"]
menu_list =["D- display details"]
menu_list =["A - Make deposit"]
menu_list =["W- Make withdraw",]
menu_list =["S - save"]
menu_list =["Q - quit"]





creation_list = ["Account owners full name:", "starting balance: $"]
current_informatioon =["N/A","N/A","N/A"]
save_path= 'bank_accounts/'
information/_file = "information/"
current_newbank_number = open(information_file + "bankid_txt","r")
idnumber = int (current_newbank_number.readline())
current_newbank_number.close()
current_file = open(information_file, "file_txt","r")
filenames = current_files.readline()
filenames=[line.strip() for line in filenames]
current_files.close()
def save():
global current_information
save_name = open(save_path + str(current_information[0]) + ".txt,'w")
for i in current_information:
save_name.wrtie(str(i)+ "\n"):

def open():
golbal idnumber,current_informatiom
file_information = []

if current_informatiom[] != "N/A":
save()
file_information.append(int(idnumber))
idnumber: +=1
print("type c at any point to abort creation")
for i in creation_list:
value = input("\t" + i)
if value.upper() == "C":
menu()
else:
file_information.append(value)
file_information.append(time.strftime("%d%r%y) + "+account opened- $" +file_information[2])
current_information = files_information
current_information = file_information
save_name = open(save_path + str(file_information [0]) + ".txt", 'w')
for i in file_informatio;
save_name.write(str(i) + "\n")

current_file- = pen(information_file+str("file.txt",'w')
filename.append(file_information[0])
for i in filenames:
current_files_.wirte(str(i] + "\n")
id_file = open(information_file + "bankid.txt","w")
id_file.write(idnumber)

def deposit():
amount ==int(input("how much would you like to to deposit?"))
current_information[2] = int(current_informatiom[2]) + amount
current_informatiom.append(time.strftime("%d/%r/%y) + "-deposit - $" + str(amount))

def withdraw():
amount ==int(input("how much would you like to to withdraw?"))
current_information[2] = int(cuurnt_informatiom[2]) - amount
current_informatiom.append(time.strftime("%d/%r/%y) + -deposit - $" + str(amount))

def quit():
if current_information[0] != "N/A":
quit()
def load():
global current_information
count = 0
if current_informatioon[0] != "N/A":
save()
print()
print("|t", '***file list**")\for i in file name:
count += 1
print (count,1)
if count==0:
print("File list is empty")

print("TYpe C to go back to the menu")
print("Which file woulf you like")
selection = input()
if selection.upper == 'C':
menu()
elif int(selectiom) > and int(selection) <= len (filenames):
load_file = open(save_path +str(filename[int(selection)-1])+".txt,'r')
load_info = load_file.readline()
current_information =[line.strip() for line in load info]
print(current_information)
else:
pass
def display ();
print ()
print("Account balance:$" +str(current_information[2]))
if len(current_information)> 
:
print("Account history:")
for i in range(3, len{current_informatiom)):
print(current_information[1])
else:
print("No account loaded")

def menu()
menu_ = True
while menu_:
if current_informatiom[0] != "N/A":
print()
print("current loaded accoint:")
print("coustomer number:", current_information[0])
print("coustomer name:",current_information[1]
print("coustomer balance: $" + str(current_information[2]))
save()

print("load or create an account")
print()
print("***bank sysytem***")
for i in menu_list:
print("\tt,i)
command = input("command:")
if command.upper() == "O":
open_()
elif(comman.upper() =="l":
load_()
elif(comman.upper() =="a":
deposit_()
elif(comman.upper() =="W":
withdraw_()
elif(comman.upper() =="s":
save_()
elif(comman.upper() =="q":
quit_()

print("not a valid entry"0

menu()



More information about the Python-list mailing list