0% found this document useful (0 votes)
7 views2 pages

LAB4

The document outlines the development of a banking system with SavingsAccount and CurrentAccount classes inheriting from a BankAccount base class, detailing their attributes and methods. It also describes a Hybrid Car system using multiple inheritance from ElectricVehicle and FuelVehicle, specifying their attributes and methods. Additionally, it includes a task to design class and interaction diagrams for an e-voting system with custom classes.

Uploaded by

santypravin3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

LAB4

The document outlines the development of a banking system with SavingsAccount and CurrentAccount classes inheriting from a BankAccount base class, detailing their attributes and methods. It also describes a Hybrid Car system using multiple inheritance from ElectricVehicle and FuelVehicle, specifying their attributes and methods. Additionally, it includes a task to design class and interaction diagrams for an e-voting system with custom classes.

Uploaded by

santypravin3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. You are developing a banking system that needs to handle different types of accounts.

There are two main types of accounts: SavingsAccount and CurrentAccount, both of
which inherit from a base class BankAccount.

Requirements:

1. BankAccount (Base Class)


o Attributes: accountNumber, balance
o Methods:
 deposit(double amount): Adds the amount to the balance
 withdraw(double amount): To be overridden in derived classes
2. SavingsAccount (Derived from BankAccount)
o Additional Attribute: interestRate
o Method:
 applyInterest(): Adds interest to the balance
3. CurrentAccount (Derived from BankAccount)
o Additional Attribute: overdraftLimit
o Method Override:
 withdraw(double amount): Allows withdrawal up to
overdraftLimit

Task:

Write a C++ program to implement the above scenario.


Then, create objects of both SavingsAccount and CurrentAccount, perform deposits and
withdrawals, and display the final balance.

2.You are designing a Hybrid Car system that combines features from both Electric
Vehicles (EVs) and Fuel-Based Vehicles. The goal is to create a hybrid car that inherits
properties from both types of vehicles using multiple inheritance.

Requirements:

1. Base Class 1: ElectricVehicle


o Attributes: batteryCapacity (in kWh)
o Methods:
 chargeBattery(double amount): Increases battery capacity

2. Base Class 2: FuelVehicle


o Attributes: fuelCapacity (in liters)
o Methods:
 refuel(double amount): Increases fuel level

3. Derived Class: HybridCar (Inherits from ElectricVehicle & FuelVehicle)


o Additional Attribute: mode (string: "Electric" or "Fuel")
o Methods:
 drive(double distance):
 If mode is Electric, reduce battery capacity.
 If mode is Fuel, reduce fuel level.
 switchMode(string newMode): Switch between Electric and Fuel mode.

Task:

1. Implement the above classes in C++.


2. Create a HybridCar object, charge its battery, refuel it, switch modes, and simulate a drive.
3. Display the remaining battery and fuel levels.

3. Design a Class Diagram and interaction Diagram for e-voting system. Create your own
classes and list the attributes and methods for each of them.

You might also like