Here is a clean, polished, professional README.md written exactly for your Vehicle Management System program based on the code and explanation you provided. Simple, clear, and submission-ready.
A Java program that demonstrates Object-Oriented Programming concepts using an inheritance hierarchy of vehicles. The project models different types of vehicles (Car, Motorcycle, Truck) using abstraction, inheritance, method overriding, and polymorphism.
-
Abstract Base Class (Vehicle): Defines common properties (brand, model) and shared behavior.
-
Child Classes (Car, Motorcycle, Truck): Each vehicle type extends the base class and provides its own behavior.
-
Method Overriding: Child classes override methods like
startEngine()anddisplayInfo(). -
Polymorphism (Run-time): A list of
Vehicleobjects can store different types of vehicles. The JVM automatically selects the correct method implementation at runtime. -
Encapsulation & Constructor Chaining: Uses
super()to initialize parent class attributes.
VehicleManagementSystem/
│── Vehicle.java # Abstract parent class
│── Car.java # Child class extending Vehicle
│── Motorcycle.java # (Optional) Child class extending Vehicle
│── Truck.java # (Optional) Child class extending Vehicle
│── VehicleManager.java # Main class demonstrating polymorphism
- Contains common fields:
brand,model - Provides shared methods:
displayInfo(),stopEngine() - Declares abstract method:
startEngine()(must be overridden)
- Extends
Vehicle - Adds unique field:
numberOfDoors - Implements
startEngine()using its own behavior - Overrides
displayInfo()to show extra details - Adds a child-specific method:
openTrunk()
-
Creates a list of type
Vehicle -
Stores
Carobjects inside it (and can store Motorcycle, Truck, etc.) -
Demonstrates dynamic method dispatch
-
Calls:
displayInfo()→ overridden versionstartEngine()→ polymorphic versionstopEngine()→ inherited version
-
Shows how to call child-specific methods using casting
javac *.javajava VehicleManager--- 🌍 Vehicle Management System Demo ---
--- Vehicle Information ---
Brand: Toyota
Model: Camry
Doors: 4
**Car Engine Started:** The Toyota Camry key is turned.
Toyota Camry engine stopped.
---------------------------------
Toyota Camry trunk is open.
| Concept | Explanation | Where Used |
|---|---|---|
| Inheritance | Child classes reuse attributes & methods from parent | class Car extends Vehicle |
| Abstract Class | Base class with common code + abstract behavior | Vehicle |
| Method Overriding | Child provides custom behavior | Car.startEngine() |
| Polymorphism | Parent reference → Child object | List<Vehicle> vehicles |
| Dynamic Dispatch | JVM selects method at runtime | v.startEngine() inside loop |
| Encapsulation | Fields hidden, accessed through constructor | brand, model |
- Implement full versions of
MotorcycleandTruck - Add fuel type, engine CC, load capacity, etc.
- Add interactive menu for adding/removing vehicles
- Store vehicle data in a file or database
Name: Pirakala Sushwanth
Register Number: 24MIM10048
Course: Programming in Java