Introduction
Introduction
Introduction :-
Source Code :-
import pickle
import os
import pathlib
class Account :
accNo = 0
name = “
deposit =0
type = “
print(“\n\n\nAccount Created “)
print(“Balance : “,self.deposit)
def modifyAccount(self) :
def depositAmount(self,amount):
self.deposit += amount
self.deposit -= amount
def getAccountNo(self):
return self.accNo
def getAccountHolderName(self):
return self.name
def getAccountType(self):
return self.type
def getDeposit(self):
6
return self.deposit
def intro():
print(“\t\t\t\t***************************”)
print(“\t\t\t\t***************************”)
input()
def writeAccount():
account = Account()
account.createAccount()
writeAccountsFile(Account)
def displayAll():
file = pathlib.path(“account.data”)
if file.exists ():
infile = open (‘accounts.data’,’rb’)
7
mylist = pickle.load(infile)
infile.close()
else:
def displays(num):
if file.exists ():
mylist = pickle.load(infile)
infile.close()
found = false
for item in mylist :
if item.accNo == num:
8
found = true
else :
if not found :
def depositAndWithdraw(num1,num2):
file = pathlib.path(“accounts.data”)
if file.exists ():
mylist = pickle.load(infile)
infile.close()
os.remove (‘accounts.data’)
for item in mylist :
if num2 == 1:
9
item.deposit += amount
item.deposit-=amount
else :
else:
pickle.dump(mylist, outfile)
outfile.close()
os.rename(‘newaccounts.data’,’accounts.data’)
10
def deleteAccount(num):
file = pathlib.path(“accounts.data”)
if file.exists ():
infile = open(‘accounts.data’,’rb’)
oldlist = pickle.load(infile)
infile.close()
newlist[]
if item.accNo != num:
newlist.append(item)
os.remove(‘accounts.data’)
outfile = open(‘newaccounts.data’,’wb’)
pickle.dump(newlist,outfile)
outfile.close()
os.rename(‘newaccounts.data’,’accounts.data’)
def modifyAccount(num):
if file.exists():
infile = open(‘accounts.data’,’rb’)
oldlist = pickle.load(infile)
infile.close()
os.remove(‘accounts.data’)
if item.accNo == num
outfile = open(‘newaccounts.data’,’wb’)
pickle.dump (oldlist,outfile)
outfile.close ()
os.rename(‘newaccounts.data’, ‘accounts.data’)
def writeAccountsFile(account) :
12
if file.exists ():
oldlist = pickle.load(infile)
oldlist.append(account)
infile.close()
os.remove(‘accounts.data’)
else:
oldlist = [account]
outfile.close()
os.rename(‘newaccounts.data’,’accounts.data’)
Ch=’’
13
Num=0
Intro()
While ch !=8
#system(“cls”);
print(“\tMAIN MENU”)
print(“\t8. EXIT”)
ch = input()
#system(“cls”);
14
if ch == ‘1’:
writeAccount()
elif ch == ‘2’:
depositAndWithdraw(num,1)
elif ch ==’3’:
depositAndWithdraw(num,2)
elif ch == ‘4’:
num = int(input(“\tEnter the account no: ”))
displaysp(num)
elif ch ==’5’
displayAll();
elif ch==’6’
deleteAccount(num)
elif ch==’7’
15
modifyAccount(num)
elif ch==’8’:
break
else:
print(“Invalid choice”)