OOP Assignment 5
OOP Assignment 5
Scenario:
An academic institution needs to manage the hierarchy of its employees, which includes
general staff, faculty, and administrators. Each employee has a salary, but faculty members
also have office hours and a rank. The system needs to keep track of these attributes and
allow for customized printing of details based on the type of employee.
Task Description:
1. Create a base class Person with fields for name, address, phone number, and email
address.
2. Extend Person to create an Employee class with fields for salary and the date of
hiring.
3. Further extend Employee to create a Faculty class that adds fields for office hours and
rank.
4. Override the toString() method in each class to output customized details for each
type of person.
5. Write a main program to create objects for a generic person, employee, and faculty
member, then print their details using the overridden toString() methods.
Task #2
Scenario:
A company needs to track shipments of products, which have multiple layers of attributes
such as size, weight, and shipping costs. The system must calculate the volume, weight, and
total cost of shipping a product based on its attributes.
Task Description:
1. Create a Box class with width, height, and depth, along with a method to calculate the
volume.
2. Extend Box to a BoxWeight class, which adds a weight attribute.
3. Extend BoxWeight into a Shipment class, which adds a cost attribute for shipping.
4. Write a main program that creates shipment objects, calculates and displays their
volume, weight, and shipping cost.
Task #3
Scenario:
A banking application needs to manage different types of accounts, including savings and
checking accounts. The system should ensure that all accounts can perform common operations
such as deposits and withdrawals, while also allowing for specific implementations based on
the type of account.
Task Description:
Task 4:
Scenario:
An educational institution needs to manage various staff roles, including faculty and
administrative personnel. It requires a system that distinguishes between different types of
employees while enforcing specific rules about roles and responsibilities.
Task Description:
Task #5
You have been assigned the responsibility of designing a Fleet Management System for a
transportation company that manages various vehicle types, specifically Sedans and Cargo
Trucks. This system must leverage the principles of inheritance, constructor overloading,
and method overriding to efficiently handle the specifications and operations of each vehicle
type.
CODE:
class Vehicle {
this.manufacturer = manufacturer;
this.model = model;
this.manufacturingYear = manufacturingYear;
return "Manufacturer: " + manufacturer + ", Model: " + model + ", Year: " + manufacturingYear;
@Override
this.cargoCapacity = cargoCapacity;
@Override
System.out.println(sedan.displayDetails());
System.out.println(truck.displayDetails()); } }