Question: (a) Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current account.
2

## Include member functions:-

• Accept deposit from a customer and update the balance
• Display the balance
• Compute and deposit interest
• Permit withdrawal and update balance
• Check for minimum balance, impose penalty and update the balance

## (c) Explain association and aggregation with suitable example.

Marks: 4 M, 8 M

Year: Dec 2013

 modified 3.5 years ago  • written 3.5 years ago by Sayali Bagwe • 2.4k
0

## (b) For above problem statement, implement class account, current account and saving

class Account
{
String cust_name;
int acc_no;
double balance;
String type_of_account
public void withdraw()
{
}
public void deposit()
{
}
public void display()
{
}
public void updateBal()
{
}
}
class Current extends Account
{
double servicecharge;
String chequebook;

public void issueCheque()
{
}
public void checkBal()
{
}
public void imposePenalty()
{
}
}
class Saving extends Account
{
double interest;
public void computeInterest()
{
}
public void depositInterest()
{
}
}


## (c) Explain association and aggregation with suitable example.

Association:

• When a classes are connected together conceptually, that connection is called an association.
• When one class associated with another, each one usually plays a role within that association.
• One can show each class’s role by writing it next to the class. Here is an example:
• The association between a player and a team, we can call this association as “player plays for a team”.

We can create the association by drawing a line between two classes and writing name over it.

• There can be more than one association between the two classes. For example, if the team is professional, it’s an employer and the player is an employee. Then the diagram can be drawn as:

Aggregation:

• Sometimes, a class consists of a number of component classes. This type of relation between class and its various components is called as aggregation.
• The components and the class they constitute are in a part-whole association.
• For example, a desktop computer system is an aggregation that consists of a CPU box, a keyboard, a mouse, a monitor, a CD-ROM drive, a hard drive, a RAM, a graphics card, a sound card and probably more items.
• We can represent an aggregation as a hierarchy with the whole class as computer system and components below it.
• A line joins a whole to a component, with an open diamond on a line near the whole.