Assignment 4-A

Design a Class Hierarchy

Design and implement a complete class hierarchy demonstrating OOP principles. Apply inheritance, polymorphism, and encapsulation to build a real-world object model.

5-6 hours
Intermediate
125 Points
Submit Assignment
What You'll Practice
  • Design classes and objects
  • Implement inheritance hierarchies
  • Apply polymorphism effectively
  • Use encapsulation for data hiding
  • Work with interfaces and abstract classes
Contents
01

Assignment Overview

In this assignment, you'll design and implement a complete object-oriented system. You'll create a class hierarchy for a Vehicle Management System that demonstrates all four pillars of OOP: Abstraction, Encapsulation, Inheritance, and Polymorphism.

Skills Applied: Classes & Objects (4.1), Inheritance (4.2), Polymorphism (4.3), and Encapsulation (4.4) from Module 4.
Classes

Design proper class structures with constructors

Inheritance

Create parent-child class relationships

Polymorphism

Override methods and use interfaces

Encapsulation

Hide data with access modifiers

02

Requirements

Part 1: Abstract Base Class (30 points)

  • Create an abstract Vehicle class with common properties
  • Include: make, model, year, price, fuelType
  • Define abstract methods: startEngine(), calculateFuelEfficiency()
  • Implement proper constructors and encapsulation

Part 2: Concrete Classes (35 points)

  • Create Car class extending Vehicle (add: numDoors, trunkCapacity)
  • Create Motorcycle class extending Vehicle (add: engineCC, hasABS)
  • Create Truck class extending Vehicle (add: payloadCapacity, numAxles)
  • Implement all abstract methods appropriately for each type

Part 3: Interfaces (30 points)

  • Create Rentable interface with methods: calculateRentalCost(int days), isAvailable()
  • Create Serviceable interface with methods: scheduleService(), getServiceHistory()
  • Implement interfaces in appropriate vehicle classes
  • Demonstrate interface polymorphism

Part 4: Demonstration (30 points)

  • Create a VehicleManager class with an array of vehicles
  • Demonstrate polymorphism by iterating through different vehicle types
  • Show interface usage with rental and service operations
  • Include a main method with comprehensive testing
03

Submission Guidelines

Folder Structure: Submit all files in a folder named assignment4_yourname
Required Files:
  1. Vehicle.java - Abstract base class
  2. Car.java, Motorcycle.java, Truck.java
  3. Rentable.java, Serviceable.java - Interfaces
  4. VehicleManager.java
  5. Main.java - Test program
  6. UML_Diagram.png/pdf - Class diagram
  7. README.txt
Ready to submit? Include a UML diagram of your class hierarchy!
Submit Now
04

Grading Rubric

Criteria Points Description
Abstract Base Class 30 Proper abstraction with abstract methods
Concrete Classes 35 Correct inheritance and method implementation
Interfaces 30 Proper interface design and implementation
Demonstration 30 Polymorphism demonstrated effectively
Total 125