Object Orientation Programming (Oop) Lab
Object Orientation Programming (Oop) Lab
Programming
(OOP)LAB
Project 1
Instructor: Atif Bajwa
Group Members:
Hasnain Ahmed (2012216)
Dasnish Ahmed(2012209)
Bilal Atiq (2012237)
Introduction
Define a class for a bank account that includes the following data members:
Name of the depositor
Account Number
Type of account
Balance amount in the account
The class also contains the following member functions:
A constructor to assign initial values
Deposit function to deposit some amount. It should accept the amount as parameter.
Withdraw function to withdraw an amount after checking the balance. It
should accept the amount as parameter.
Display function to display name and balance.
Data members
In our first lab project of object oriented programming we made a class named as “ bank “ having the following
data members
Private:
First we initialize the data members as private:
The class members declared as private can be accessed only by the functions inside the class
They are not allowed to be accessed directly by any object or function outside the class.
Only the member functions or the friend functions are allowed to access the private data members of a
class
Member function declaration:
In public we create a construct name bank as same class name
We also declare member function in public and passing amount as a parameter in member function
And declare function inside the class and function definition outside the class
Public:
All the class members declared under public will be available to everyone
The data members and member functions declared public can be accessed by other classes too.
The public members of a class can be accessed from anywhere in the program using the direct member
access operator (.) with the object of that class.
void data();
Void deposit(int amount);
Void withdraw (int amount);
Void display ();
Member Function Defination
We declare member function inside the class but definition out side the class we can access it by dot
operator(.)
Main function:
If the user choose the deposit money option then it asks about the money to be deposited.after entering
money it shows total amount after being deposited.
If the user choose the withdraw money option then it asks about the money to be withdrawn from the
account.first it checks that the withdraw money entered is less than or greater than available money.if it is
greater then it would show error otherwise it would show the remaining money in the account after
withdrawn amount.
if user choose display function then it will show name of depositor and current balance.