Bank System

Banking System

Header Files: 


#pragma once
#include<iostream> 
#include <string>
using namespace std;


class Manager {
private:
string name;
    string id;
public:
Manager(string ="", string  = "");
void setData(string ="", string ="");
string getName();
string getID();
friend ostream& operator<<(ostream&, Manager&);
};

class Account {
private:
string account_Type;
int account_No;
int customer_Id;
string customer_Name;
double balance;
public:
Account(string = "", string = "", int = 0, int = 0, double = 0);
void setData(string, string, int, int, double);
void deposit(int, int);
void withDraw(int, int);
void inquiry(int, int);
void closeAccount(int, int);
void modify(int, int);
string getAccountType();
int getAccount_No();
double getBalance();
friend ostream& operator<<(ostream&, Account&);

};


class Customer {
private:
string name;
int id;
Account obj;
public:
Customer(string = "", int = 0, string = "", string = "", int = 0, int = 0, double = 0);
void setname(string);
void setId(int);
void setAccount(string, int, double);
void deposit(int, int);
void withDraw(int, int);
void inquiry(int, int);
void modify(int, int);
void closeAccount(int, int);
string getName();
int getId();
Account getAccount();
friend ostream& operator<<(ostream&, Customer&);
};


class Bank {
private:
Manager* manager;
string bank_name;
public:
Bank(string = "RANDOM BANK");
void setAccount(string, int, double,Customer&);
void deposit(int, int,Customer &);
void withDraw(int, int, Customer&);
void inquiry(int, int, Customer&);
void modify(int, int, Customer&);
void closeAccount(int, int,Customer&);
void setData(Manager*, string = "");
string bankName();
friend ostream& operator << (ostream&, Bank&);
~Bank();

};


Class Definitions: 

#include"Bank.h"
#include<iostream>
using namespace std;

Manager::Manager(string n, string id)
{
name = n;
this->id = id;
}

void Manager::setData(string n, string id)
{
name = n;
this->id = id;

}

ostream& operator<<(ostream& out, Manager& manager)
{
out << "Manager Name: " << manager.name << endl;
out << "Manager ID:   " << manager.id << endl;
return out;
}
string Manager::getName()
{
return name;
}





string Manager::getID()
{
return id;
}


string Bank::bankName()
{
return bank_name;
}

Bank::Bank(string n)
{
bank_name = n;
manager = new Manager;
}

void Bank::setData(Manager* m,string n)
{
manager->setData(m->getName(), m->getID());
bank_name= n;
}
void Bank::setAccount(string n, int no, double b,Customer& c)
{
c.setAccount(n, no, b);
}

void Bank::deposit(int id,int accNo,Customer &obj)
{
obj.deposit(id, accNo);
}
void Bank::withDraw(int id, int accNo, Customer& obj)
{
obj.withDraw(id, accNo);
}
void Bank::inquiry(int id, int accNo, Customer& obj)
{
obj.inquiry(id, accNo);
}
void Bank::closeAccount(int id, int accNo, Customer& obj)
{
obj.closeAccount(id, accNo);
}
void Bank::modify(int id, int accNo, Customer& obj)
{
obj.modify(id, accNo);
}
Bank::~Bank()
{
delete manager;
}

ostream& operator<<(ostream& out, Bank& b)
{
out << "Bank Name: " << b.bank_name << endl;
out << "Manager: " << b.manager->getName() << endl;
return out;
}


//Customer Class


Customer::Customer(string n, int i, string t, string na, int no, int id, double b)
{
name = n;
id = i;
obj.setData(t, na, no, id, b);
}
void Customer::setname(string n)
{
name = n;
}

void Customer::setId(int i)
{
id = i;
}

void Customer::setAccount(string type, int no, double b)
{
obj.setData(type, name, no, id, b);
}

void Customer::deposit(int id,int accNo)
{
obj.deposit(id,accNo);
}

void Customer::withDraw(int id, int accNo)
{
obj.withDraw(id, accNo);
}
void Customer::inquiry(int id, int accNo)
{
obj.inquiry(id, accNo);
}

void Customer::closeAccount(int id, int accNo)
{
obj.closeAccount(id, accNo);
}

void Customer::modify(int id, int accNo)
{
obj.modify(id, accNo);
}

string Customer::getName()
{
return name;
}

int Customer::getId()
{
return id;
}

Account Customer::getAccount()
{
return obj;
}

ostream& operator<<(ostream& out, Account& a)
{
out << "Account Type: " << a.account_Type << endl;
out << "Account Number: " << a.account_No << endl;
out << "Customer Id: " << a.customer_Id << endl;
out << "Account Balance: " << a.balance << endl;
return out;
}


//Account Class

Account::Account(string type,string name, int no, int id, double b)
{
account_Type = type;
customer_Name = name;
account_No = no;
customer_Id = id;
balance = b;
}
void Account::setData(string type, string name, int no, int id, double b)
{
account_Type = type;
customer_Name = name;
account_No = no;
customer_Id = id;
balance = b;
}
void Account::deposit(int id, int accNo)
{
if (id == customer_Id && accNo == account_No)
{
cout << "\n\t\t\t   ACCOUNT STATUS\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nAccount Holder Name: " << customer_Name;
cout << "\n\nType of Account: " << account_Type;
cout << "\n \nBalance amount: " << balance;
cout << "\n\n\tEnter Amount to Deposit:  ";
double amount;
cin >> amount;
{
balance = balance + amount;
}
cout << "\n\n\t\t\tRecord Updated";
cout << "\n\nNew Balance is:  " << balance << endl<<endl;
}
else cout << "\n\nInvalid ID ...NO Record Found....\n\n";
}

void Account::withDraw(int id, int accNo)
{
if (id == customer_Id && accNo == account_No)
{
cout << "\n\t\t\t   ACCOUNT STATUS\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nAccount Holder Name: " << customer_Name;
cout << "\n\nType of Account: " << account_Type;
cout << "\n\nBalance amount: " << balance;
cout << "\n\n\t\tEnter Amount to WithDraw:";
double amount;
cin >> amount;
{
balance = balance - amount;
}
cout << "\n\n\t\t\tRecord Updated";
cout << "\n\nNew Balance is:  " << balance << endl << endl;
}
else cout << "Invalid ID\n";
}

void Account::inquiry(int id, int accNo)
{
if (id == customer_Id && accNo == account_No)
{
cout << "\n\t\t\t   ACCOUNT STATUS\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nAccount Holder Name: " << customer_Name;
cout << "\n\nType of Account: " << account_Type;
cout << "\n \nBalance amount: " << balance;
}
else cout << "Invalid ID\n";
}

void Account::closeAccount(int id, int accNo)
{
if (id == customer_Id && accNo == account_No)
{
cout << "\n\t\t\t   ACCOUNT STATUS\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nAccount Holder Name: " << customer_Name;
cout << "\n\nType of Account: " << account_Type;
cout << "\n \nBalance amount: " << balance;
{
account_No = 0;
account_Type = "";
customer_Id = 0;
customer_Name = "";
balance = 0;
}
cout << "\n\n\t\t Record Deleted Succesfully...\n";

}
else cout << "Invalid ID\n";
}
void Account::modify(int id, int accNo)
{
if (id == customer_Id && accNo == account_No)
{
cout << "\n\t\t\t   ACCOUNT STATUS\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nAccount Holder Name: " << customer_Name;
cout << "\n\nType of Account: " << account_Type;
cout << "\n \nBalance amount: " << balance;

string name, type;
double b;
cout << "\n\n\t\t\tEnter The New Details\n";
cout << "-----------------------------------------------------------------------------";
cout << "\n\nAccount No: " << account_No;
cout << "\n\nCustomer Id: " << customer_Id;
cout << "\n\nModify Account Holder Name: ";
cin >> name;
cout << "\n\nModify Account Type: ";
cin >> type;
cout << "\n\nModify Account Balance: ";
cin >> b;

customer_Name = name;
account_Type = type;
balance = b;
cout << "\n \nRecord Modified Succesfully...\n\n";
}
else cout << "\nInvalid ID\n\n";
}

string Account::getAccountType()
{
return account_Type;
}

int Account::getAccount_No()
{
return account_No;
}

double Account::getBalance()
{
return balance;
}

//ostream& operator<<(ostream& out, Account& a)
//{
// out << "Account Type: " <<a.account_Type << endl;
// out << "Account Number: " << a.account_No<< endl;
// out << "Customer Id: " << a.customer_Id << endl;
// out << "Account Balance: " << a.balance << endl;
// return out;
//}




Driver : 

// Bank system.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<string>
#include<stdlib.h>
#include"Bank.h"
using namespace std;
void menu();
void create_New_Account(Customer&,Bank& );
void deposit(Customer &,Bank& );
void withDraw(Customer&, Bank&);
void inquiry(Customer& , Bank&);
void closeAccount(Customer& c, Bank&);
void modify(Customer&, Bank&);
bool login(Bank&);

int main()
{

    Bank bank;
    Customer customer;
   
    cout << "\t---------------------------------------------------------------\n";
    cout << "\t\t\tBANK \n  \t\t\t\MANAGEMENT\n  \t\t\tSYSTEM\n";
    cout << "\t---------------------------------------------------------------\n\n";
    cout << "By (Uzair Gull): 2019-CS-674 \n\n";


    char choice;


    if (login(bank) == true)
    {
        do {

            system("pause");
            system("cls");
            menu();
            cin >> choice;
            system("cls");
            switch (choice)
            {
            case'1':
                create_New_Account(customer, bank);
                break;
            case'2':
                deposit(customer, bank);
                break;
            case'3':
                withDraw(customer, bank);
                break;
            case'4':
                inquiry(customer, bank);

                break;
            case'5':
                closeAccount(customer, bank);

                break;
            case'6':
                modify(customer, bank);
                break;
            }
        } while (choice != '7');

    }

    else {
        cout << "\nEXIT\n";
         }

}


bool login(Bank &ba)
{
    Manager manager;

    bool b=true;
    int attempts=0;
    system("pause");
    system("cls");
   
    while (1) {
        
        system("cls");
        cout << "\n\tWELCOME TO..............\n";
        cout << "\n\t\t\t\t" << ba.bankName() << endl;
        cout << "\t---------------------------------------------------------------\n";
        cout << "\nPLEASE LOGIN WITH YOUR USER NAME AND ID: \n";
        string n, id;
        cout << "\nEnter USER NAME or Manager Name: ";
        cin >> n;
        cout << "\nEnter USER ID or Manager Id: ";
        cin >> id;
        manager.setData(n, id);

        if (n == "uzair" && id == "1234")
        {
            cout << "\nSUCCESFULLY LOGIN\n\n";
            b = true;
            return b;
            break;
        }
        else
        {
            
            cout << "\n\nUSER NAME OR ID IS INCORRECT....\n\n\t\t\tPLEASE ENTER AGAIN\n\n";
            system("pause");
            b = false;
            attempts++;
        }

        
        if (attempts == 3) {
            cout << "\n\nSORRY YOU HAVE SO MANY ATTEMPTS!!!!!!!!!\n";
            break;
        }
            
    } 
    return b;
}
void menu()
{
   
    cout << "\n\t\t\t\tMAIN MENU\n\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "1. NEW ACCOUNT\n\n";
    cout << "2. DEPOSIT AMOUNT\n\n";
    cout << "3. WITHDRAW AMOUNT\n\n";
    cout << "4. BALANCE INQUERY\n\n";
    cout << "5. CLOSE AN ACCOUNT\n\n";
    cout << "6. MODIFY AN ACCOUNT\n\n";
    cout << "7. EXIT\n\n\n";
    cout << "SELECT YOUR OPTION (1-7)\n";  
}

void create_New_Account(Customer &c,Bank& b)
{
   
    
    cout << "\n\t\t\tNEW ACCOUNT ENTRY FORM\n";
    cout << "-----------------------------------------------------------------------------\n";
    cout << "\nEnter Customer ID: ";
    int id;
    cin >> id;
    c.setId(id);
    int account_No;
    cout << "\nEnter Account No: ";
    cin >> account_No;
    string name;
    cout << "\nEnter Name of the Account Holder: ";
    cin >> name;
    c.setname(name);
    cout << "\nEnter Acount Type: (Current/Saving) : ";
    string account_Type;
    cin >> account_Type;
    cout << "\nEnter initial amount:\n\n\t >= 500 or more for Saving   >= 1000 or more for Current: ";
    double initial;
    cin >> initial;
    b.setAccount(account_Type, account_No, initial,c);
    cout << "\n\n Your Account created Succesfully.. \n\n";
}

void deposit(Customer& c,Bank& b)
{
    cout << "\n\t\t\tACCOUNT TRANSACTION FORM\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "Enter Customer Id: ";
    int id;
    cin >> id;
    cout << "\nEnter Account No: ";
    int accNo;
    cin >> accNo;
    b.deposit(id, accNo,c);
 
}

void withDraw(Customer& c,Bank &b)
{
    cout << "\n\t\t\tACCOUNT TRANSACTION FORM\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "Enter Customer Id: ";
    int id;
    cin >> id;
    cout << "\nEnter Account No: ";
    int accNo;
    cin >> accNo;
    b.withDraw(id, accNo,c);
}

void inquiry(Customer& c,Bank &b)
{
    cout << "\n\t\t\tBalance Inquiry FORM\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "Enter Customer Id: ";
    int id;
    cin >> id;
    cout << "\nEnter Account No: ";
    int accNo;
    cin >> accNo;
    b.inquiry(id, accNo,c);
}

void closeAccount(Customer& c,Bank &b)
{
    cout << "\n\t\t\t\Account Deletion FORM\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "Enter Customer Id: ";
    int id;
    cin >> id;
    cout << "\nEnter Account No: ";
    int accNo;
    cin >> accNo;
    b.closeAccount(id, accNo,c);
}

void modify(Customer& c,Bank &b)
{
    
    cout << "\n\t\t\tAccount Modification FORM\n";
    cout << "-----------------------------------------------------------------------------\n\n";
    cout << "Enter Customer Id: ";
    int id;
    cin >> id;
    cout << "\nEnter Account No: ";
    int accNo;
    cin >> accNo;

    b.modify(id, accNo,c);
  
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

UML : 


Comments