0% found this document useful (0 votes)
2 views

Java Programming Assignment

Java Programming Assignment

Uploaded by

Yusuf Omar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Programming Assignment

Java Programming Assignment

Uploaded by

Yusuf Omar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Programming Assignment: Vehicle Information System

Context: You are tasked with developing a software application for a car rental
agency. The application needs to handle different types of vehicles, including cars,
motorcycles, and trucks. To enforce a common behavior and ensure consistency
among these vehicle types, you decide to utilize interfaces. Additionally, you want to
incorporate various small modules into the question to make it engaging and
interactive for the developers.

Task:

1.

Design and Implement the "Vehicle" Interface:

2.
1. Create an interface named Vehicle that includes methods for retrieving the
vehicle's make, model, and year of manufacture.
3.

Develop the "Car" Class:

4.

1. Create an interface named CarVehicle with methods for setting and retrieving
the number of doors and the fuel type (petrol, diesel, or electric).
2. Develop a class named Car that implements both Vehicle and CarVehicle
interfaces.

5.

Construct the "Motorcycle" Class:

6.

1. Create an interface named MotorVehicle with methods for setting and


retrieving the number of wheels and the type of motorcycle (sport, cruiser, or off-
road).
2. Develop a class named Motorcycle that implements both Vehicle and
MotorVehicle interfaces.

7.

Generate the "Truck" Class:

8.

1. Create an interface named TruckVehicle with methods for setting and


retrieving the cargo capacity (in tons) and the transmission type (manual or
automatic).
2. Develop a class named Truck that implements both Vehicle and
TruckVehicle interfaces.

9.

Integrate Classes into the Main Program:

10.

1. Develop a main program that allows the user to create objects of different vehicle
types, provide relevant information, and display the details of each vehicle.

Assessment Criteria:

1.

Interface Design:

2.

1. The Vehicle interface provides a contract specifying the methods for retrieving
vehicle details, ensuring a consistent structure for different vehicle types.

3.

Class Implementation:

4.

1. The Car, Motorcycle, and Truck classes translate the interface specifications
into concrete implementations, enabling the storage and retrieval of specific
attributes and behaviors.

5.

Main Program Functionality:

6.

1. The main program allows users to interactively create, input, and display details of
various vehicle objects, providing a comprehensive interface for managing and
accessing vehicle information.

7.

Code Quality:

8.
1. The code should emphasize readability, maintainability, and adherence to best
practices, ensuring a clean and well-structured codebase that promotes efficient
development and future scalability.

9.

Error Handling:

10.

1. The application should effectively manage and gracefully handle potential


exceptions or invalid user inputs, ensuring a robust and stable application
experience.

11.

Documentation:

12.

1. Provide clear and comprehensive explanations of classes, methods, and their


functionalities to aid developers in understanding and maintaining the codebase
effectively.

Instructions:

 Use appropriate variable names and follow coding best practices.


 Ensure your code is well-documented and includes comments where necessary.

Example Code Structure:


Code:
// Vehicle Interface
public interface Vehicle {
String getMake();
String getModel();
int getYearOfManufacture();
}

// CarVehicle Interface
public interface CarVehicle {
void setNumberOfDoors(int doors);
int getNumberOfDoors();
void setFuelType(String fuelType);
String getFuelType();
}

// Car Class
public class Car implements Vehicle, CarVehicle {
private String make;
private String model;
private int yearOfManufacture;
private int numberOfDoors;
private String fuelType;

// Implement the methods from Vehicle and CarVehicle


// ...
}

// MotorVehicle Interface
public interface MotorVehicle {
void setNumberOfWheels(int wheels);
int getNumberOfWheels();
void setType(String type);
String getType();
}

// Motorcycle Class
public class Motorcycle implements Vehicle, MotorVehicle {
private String make;
private String model;
private int yearOfManufacture;
private int numberOfWheels;
private String type;

// Implement the methods from Vehicle and MotorVehicle


// ...
}

// TruckVehicle Interface
public interface TruckVehicle {
void setCargoCapacity(double capacity);
double getCargoCapacity();
void setTransmissionType(String transmission);
String getTransmissionType();
}

// Truck Class
public class Truck implements Vehicle, TruckVehicle {
private String make;
private String model;
private int yearOfManufacture;
private double cargoCapacity;
private String transmissionType;

// Implement the methods from Vehicle and TruckVehicle


// ...
}

// Main Program
public class VehicleInformationSystem {
public static void main(String[] args) {
// Code to create and manage different vehicle objects
// ...
}
}

You might also like