Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Amrita School of Computing, Coimbatore

23CSE111 - Object Oriented Programming


Evaluation - 3
Marks : 30 Marks

Create a system to manage a fleet of vehicles for a transportation company. The system
should classify vehicles based on their type and handle specific behaviors and characteristics
for each type. The vehicles can be categorized as cars, trucks, and motorcycles, each with
unique properties and behaviors.

Requirements:

1. Vehicle Interface:
- Define an interface Vehicle with the following methods:
• void startEngine()
• void stopEngine()
• void refuel(int amount)

2. Abstract Class MotorVehicle :


- Create an abstract class MotorVehicle that implements the Vehicle interface. This class
should have the following attributes and methods:
- Attributes:
• String licensePlate
• String model
• double fuelLevel
- Methods:
• void startEngine()
• void stopEngine()
• void refuel(int amount)
• abstract void displayDetails()

3. Car Class:
- Create a class Car that extends MotorVehicle . This class should have the following
additional attributes and methods:
- Attributes:
• int numberOfDoors
- Methods:
• Override the displayDetails method to include information about the number of
doors.

4. Truck Class:
- Create a class Truck that extends MotorVehicle . This class should have the following
additional attributes and methods:
- Attributes:
• double loadCapacity
- Methods:
• Override the displayDetails method to include information about the load
capacity.

5. Motorcycle Class:
- Create a class Motorcycle that extends MotorVehicle . This class should have the
following additional attributes and methods:
- Attributes:
• boolean hasSidecar
- Methods:
• Override the displayDetails method to include information about whether it has a
sidecar.

6. Fleet Class:
- Create a class Fleet that manages a collection of MotorVehicle objects. This class should
have the following methods:
• void addVehicle(MotorVehicle vehicle) : Add a vehicle to the fleet.
• void removeVehicle(String licensePlate) : Remove a vehicle from the fleet using
its license plate.
• MotorVehicle findVehicle(String licensePlate) : Find and return a vehicle using its
license plate.
• void displayAllVehicles() : Display details of all vehicles in the fleet.

7. Driver Class:
- Create a class Driver that represents a driver in the transportation company. This class
should have the following attributes and methods:
- Attributes:
• String name
• String driverId
• List<MotorVehicle> assignedVehicles
- Methods:
• void assignVehicle(MotorVehicle vehicle) : Assign a vehicle to the driver.
• void unassignVehicle(MotorVehicle vehicle) : Unassign a vehicle from the driver.
• void displayAssignedVehicles() : Display details of all vehicles assigned to the driver.

Use Cases:
i. Adding Vehicles:The fleet manager can add new cars, trucks, and motorcycles to the
fleet.
ii. Assigning Vehicles: Drivers can be assigned vehicles from the fleet. The system
should ensure that vehicles are not double-assigned.
iii. Removing Vehicles: Vehicles can be removed from the fleet when they are
decommissioned or sold.
iv. Searching Vehicles: The fleet manager can search for vehicles using their license
plate to view their details or manage their status.
v. Displaying Vehicles: The system can display details of all vehicles in the fleet,
including their specific attributes based on their type.

Constraints:
i. Each vehicle must have a unique license plate.
ii. Only vehicles with a sufficient fuel level can be started.
iii. The displayDetails method should provide comprehensive information about the
vehicle, including type-specific attributes.

This problem involves using inheritance to define a common structure for motor vehicles,
implementing the Vehicle interface to enforce common behaviors, and extending the
MotorVehicle abstract class to create specific vehicle types.

Rubrics for Assessment

Class Diagram - 5 Marks


Implementation - 10 Marks
Output - 10 Marks (Minimum 5 cases must be verified)
Viva - 5 Marks
Total - 30 Marks

You might also like