OOP PROJECT
TOPIC: Bank Management system
Group Members:
Muhammad zoraiz (F2024266677)
Syed Ali Hamza (F2024266675)
Syed Mustafa Hassan (F2024266656)
Introduction:
As our semester final project, we have developed a Banking Management System. Through this
project we have gained knowledge of core OOP concepts. This program has the option to create two
accounts saving, and checking. It allows users to create accounts, transfer money, withdrawal and
deposit funds.
In this document we will first explain the elements of the program such as classes and functions and
then we will explain the flow of our code.
Components:
Classes:
The program has a total of three classes:
o
Account:
Account is the base abstract class it holds all the data.
Data Members:
int withdrawals (Protected)
string AccountNumber (Protected)
string Name (Protected)
float Balance, AmountToDepositWithdrawal (Protected)
Member Functions:
Account(), Account(string Acc, string name),Account(Account&
obj) are the default, parametrised and copy constructer respectively.
Setter and getter for each variable.
Pure virtual functions deposit(), withdraw(), displayinfo().
Virtual distruster ~Account().
Overloaded operators + and -.
And a friend function Transfer()
o savingAccount:
savingAccount is a derived class that inherits Account publicly.
Member Functions:
deposit(): This overridden function displays user the name and
account number it then prompts the user to enter amount to deposit. It
adds the amount to the balance variable which updates the balance. It
will also give user a bonus on specific amounts
withdraw(): This is a overridden function that first displays account
details. It then asks the user to enter amount withdraw if user has
sufficient balance, maintains minimum balance limit and have not
reached his monthly withdraw limit amount will be subtracted from
the balance else it will show an error message
displayinfo(): This function just displays info of the account.
o checkingAccount:
checking is a class that inherits publicly from account and provides functionality for
checking Accounts.
Member Functions:
deposit(): This overridden function displays user the name and
account number it then prompts the user to enter amount to deposit. It
adds the amount to the balance variable which updates the balance
withdraw(): This is a overridden function that first displays account
details. It then asks the user to enter amount withdraw if user has
sufficient balance amount will be subtracted from the balance else it
will show an error message. It also gives the user a $20 grace
amount.
displayinfo(): This function just displays info of the account.
Functions:
o
Menu(): This function is just used to display the menu.
o
GetValidAcc(int totalAccounts, Account *accounts[]): This function accepts
parameters int Total Account which stores the total number of accounts created
Account *accounts[] this is a pointer array of abstract class that stores all the saving
and checking account objects. It checks weather the account number entered exists if
it doses it will return the index of the object who’s account number was entered.
o
string lowercase(string word): This function takes in a word converts it into lower
case and returns it.
o
void TransferFunds(Account* from, Account* To): This function takes two
Account objects as parameter they can be saving or checking . it will prompt the user
to enter amount to transfer until user enters a amount greater than 0. it will then check
if the sender has sufficient balance if he dose it will deduct amount from sender and
add it to receiver.
o
void CreateAccount(Account *accounts[],bool &AccountCreated,int
&TotalAccounts): This function takes parameter array accounts that stores all the
accounts , bool &AccountCreated Which well tell the main weather a account is
created or not , &TotalAccounts the function will increment this variable when a
account is created.
The function first asks which account to make checking or saving
Then it asks for name
It then creates the type of account you selected.
Main():
o Variables:
Int Size: This stores the size the program will work for.
Int TotalAccount :store the numbers of accounts that have been created.
bool AccountCreated: is for checking weather a single account is
created.
Account *accounts[size]: this is an array of pointer that stores all the
accounts
string choice : This is to store the choice user enters.
Flow of the program:
In this section we will describe the flow of our program
The flow starts from the main() function .
First variables are defined.
User is prompted to enter the size he wants the program to run for.
An array of pointer of type Account is created of the entered size to store all the accounts.
The program enters a do while loop that run until the total account are less than or equal to
size this mean when the array is full the loop will end. After loop ends a program ended
statement is printed.
In the loop first of all the menu function is called and it prints the menu.
In a do while loop the user is prompted to enter input and it asks for input until the user enters
a valid input
If the choice entered was “1” CreateAccount function is called.
The flow then transfers to the CreatAccount function.
The accounts array, TotalAccounts and AccountCreated are passed as parameters.
In this function first the user is prompted to enter the type of account he wants to make the
user is asked to enter input using a do while loop until he enters a valid input i.e. “checking”
or “Saving” the input is converted to lower case using lowercase function to handle case
errors.
If the type was checking it will cerate a new checking account object and store it in the
accounts array. The name is directly passed to the parameterised constructor and for account
total accounts + 1000 is converted to string and passed. Doing this keeps each account
number distinct from each other. After creating the object, the total account is updated and
AccountCreated is set to true .
If the type was Savings it will cerate a new saving account object and store it in the accounts
array. The name is directly passed to the parameterised constructor and for account total
accounts + 1000 is converted to string and passed. Doing this keeps each account number
distinct from each other. After creating the object the total account is updated and
AccountCreated is set to true .
If choice entered was “4” The program will first check if a account is created or not because
you can not deposit if no account is crated. If account is not created it will give a error
account not created.
o
If account created the getvalidaccount function is called again. User is prompted to
enter account number if it exists the function returns its index
The index is given to the accounts array and deposit function is called using this operator
and the flow shifts to the deposit function in the class of which the object was this is
because of runtime polymorphism.
If the choice entered was “3” The program will first check if a account is created or not
because you can not withdraw if no account is crated. If account is not created it will give a
error account not created.
o
If account created the getvalidaccount function is called again. User is prompted to
enter account number if it exists the function returns its index
The index is given to the accounts array and withdraw function is called using this
operator and the flow shifts to the withdraw function in the class of which the object was
this is because of runtime polymorphism.
If the choice entered was “5” The program will first check if a account is created or not
because you can not view info if no account is crated. If account is not created it will give a
error account not created.
o
If account created the getvalidaccount function is called again. User is prompted to
enter account number if it exists the function returns its index
The index is given to the accounts array and diplayinfo function is called using this
operator and the flow shifts to the displayinfo function in the class of which the object
was this is because of runtime polymorphism.
If choice entered was “0” a statement is printed exiting program no matter how many
accounts created the loop will break and program ends.
If choice entered was “2” The program will first check if a account is created or not because
you can not transfer funds if no account is crated. If account is not created it will give a error
account not created.
o
If account created the getvalidaccount function is called again. User is prompted to
enter account number if it exists the function returns its index
First two variables are declared AccRec and AccSend they store the index for the receiving
and sending account object. The user is prompted to enter sender info GetValidAccount is
called and index is stored in AccSend similarly user is prompted to enter receiver account
GetValidAccount is called and index is stored in AccRec.
The transferFund function is called and both accounts are given as parameters.
Conclusion:
In conclusion this project taught us many core oop concepts including runtime polymorphism,
operator overloading. Moreover, through this project we learned how important is oop in making
efficient and bug free programs. We hope to use this knowledge in our practical work.