Sunteți pe pagina 1din 4

Assignment No.

02
Semester: Fall 2014
CS304: Object Oriented Programming

Total Marks: 20
Due Date: 08/12/2014

Instructions:
Please read the following instructions carefully before submitting assignment. It should be clear that your
assignment will not get any credit if:
The assignment is submitted after due date.
The submitted assignment does not open or file is corrupt.
Assignment is copied(partial or full) from any source (websites, forums, students, etc)

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will
be awarded with zero marks. For example, if you submit code in .doc (Microsoft Word Document) or .txt files
or .exe file, no reward will be given in any case.

Objective:
The objective of this assignment is to provide hands on experience of:

Relationships among classes


Constructors
Constructor overloading
Getter and Setter functions

Guidelines:

Code should be properly indented and well commented.


Follow C/C++ guide lines while writing variable names, function names etc
Use only dev-C++ for this assignment.

For any query about the assignment, contact at cs304@vu.edu.pk

Assignment

Problem Statement:
In this assignment you will be modeling a part of simple banking system. In this system, there are two classes,
Customer and Account which are related to each other via aggregation relationship.

Account class has the following data members:

Account No.
Current Balance
Bank name
Branch code

Account class must have the following member functions:


Function
Account()
Account(float, int, char *,
int)
withdraw(float)

deposit(float)
getBalance()
getAccountNo()
getBankName()
getBrachCode()

Description
Default constructor for account class, setting account balance to 0,
Account number to 1, branch name to NULL and branch code to 0
It will take balance, account no, bank name and branch code as
arguments and set their values accordingly
This will subtract amount from the balance of account that will be
passed as its parameter.
If the amount being withdrawn is greater the balance of the account
, it will display the message Insufficient balance
Function will add amount to the balance of account. Amount will
be passed as its parameter.
This function will return the value of available balance
This function will return the account number
This function will return the name of bank
This function will return branch code of bank

Customer class has the following data members:

Customer Name
Address
Account object

Customer class must have the following member functions:


Function
display()
Parameterized constructor

Description
This function will display the values of all data members
of Customer and Account class
It will take Account, name and address as a arguments and
set their values accordingly

Within main() function, objects of both classes will be created , and respective member functions of these objects
will be called.
First of all create an object of Account class by passing balance, account number, bank name and branch code.
Then create an object of customer class by passing Account object, name and address. Now call display() function
which will display all the values of Customer including his/her name, address and account detail.
The program should prompt the user to enter a value and call deposit() function passing it entered value. Then call
the display() function.
After this, the program should prompt the user to enter a value and call withdraw() function passing it entered
value. Then call the display() function.
Sample output of the program:

BEST OF LUCK!

S-ar putea să vă placă și