0% found this document useful (0 votes)
16 views16 pages

Graded Lab 3

Uploaded by

zblking370
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views16 pages

Graded Lab 3

Uploaded by

zblking370
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Graded lab 3

Five different scenario statements demonstrating


single-level inheritance in object-oriented
programming:

1. Vehicle and Car:


Scenario: In a vehicle management system, a `Car` class
inherits from a `Vehicle` class. The `Vehicle` class
includes properties like `make`, `model`, and `year`, and
methods like `startEngine` and `stopEngine`. The `Car`
class extends this by adding properties specific to cars,
such as `numberOfDoors`, and methods like
`playRadio`.
2. Employee and Manager:
Scenario: In a company's HR system, a `Manager` class
inherits from an `Employee` class. The `Employee` class
includes basic employee information such as `name`,
`employeeID`, and `department`, and methods like
`clockIn` and `clockOut`. The `Manager` class adds
additional properties such as `teamSize` and methods
like `conductMeeting`.
3. Shape and Circle:
Scenario: In a graphics application, a `Circle` class
inherits from a `Shape` class. The `Shape` class provides
basic properties like `color` and `position`, and methods
like `draw` and `move`. The `Circle` class introduces
properties specific to circles, such as `radius`, and
methods like `calculateArea`
4. Appliance and WashingMachine:
Scenario: In a smart home application, a
`WashingMachine` class inherits from an `Appliance`
class. The `Appliance` class includes properties like
`brand`, `power`, and `status`, and methods such as
`turnOn` and `turnOff`. The `WashingMachine` class
adds specific properties like `loadCapacity` and
methods such as `startWashCycle`.
5. Animal and Dog:
Scenario: In a zoological software, a `Dog` class inherits
from an `Animal` class. The `Animal` class provides
general properties such as `species`, `age`, and
`habitat`, and methods like `eat` and `sleep`. The `Dog`
class includes specific properties like `breed` and
`barkSound`, and methods such as `bark` and `fetch`.
Here are five different scenario statements
demonstrating multi-level inheritance in object-
oriented programming:

1. Device, Smartphone, and AndroidPhone:


Scenario: In a mobile device management system, an
`AndroidPhone` class inherits from a `Smartphone`
class, which in turn inherits from a `Device` class. The
`Device` class includes properties like `serialNumber`
and `manufacturer`, and methods like `powerOn` and
`powerOff`. The `Smartphone` class adds properties
such as `screenSize` and methods like `makeCall`. The
`AndroidPhone` class further extends this by adding
properties like `androidVersion` and methods like
`installApp`.

2. Person, Employee, and Manager:


Scenario: In a corporate structure, a `Manager` class
inherits from an `Employee` class, which inherits from a
`Person` class. The `Person` class includes properties
such as `name`, `age`, and `address`. The `Employee`
class adds properties like `employeeID` and `jobTitle`,
and methods such as `submitTimesheet`. The
`Manager` class adds additional properties like
`managedTeam` and methods like `approveLeave`.

3. Shape, Polygon, and Triangle:


Scenario: In a geometry software, a `Triangle` class
inherits from a `Polygon` class, which in turn inherits
from a `Shape` class. The `Shape` class includes
properties like `color` and `position`, and methods like
`draw` and `move`. The `Polygon` class adds properties
like `numberOfSides` and methods like
`calculatePerimeter`. The `Triangle` class adds
properties such as `base` and `height`, and methods like
`calculateArea`.

4. Appliance, KitchenAppliance, and Blender:


Scenario: In a smart home application, a `Blender` class
inherits from a `KitchenAppliance` class, which inherits
from an `Appliance` class. The `Appliance` class includes
properties like `brand`, `power`, and `status`, and
methods such as `turnOn` and `turnOff`. The
`KitchenAppliance` class adds properties specific to
kitchen use, such as `isDishwasherSafe`, and methods
like `adjustTemperature`. The `Blender` class includes
properties like `bladeSpeed` and methods such as
`blend`.

5. Vehicle, Car, and ElectricCar:


Scenario: In an automotive management system, an
`ElectricCar` class inherits from a `Car` class, which in
turn inherits from a `Vehicle` class. The `Vehicle` class
includes properties like `make`, `model`, and `year`, and
methods like `startEngine` and `stopEngine`. The `Car`
class adds properties such as `numberOfDoors` and
methods like `playRadio`. The `ElectricCar` class further
extends this by adding properties like `batteryCapacity`
and methods such as `chargeBattery`.
Here are five different scenario statements
demonstrating multiple inheritance, where a class can
inherit from more than one base class:

1. FlyingCar from Vehicle and Aircraft:


Scenario: In a futuristic transportation system, a
`FlyingCar` class inherits from both `Vehicle` and
`Aircraft` classes. The `Vehicle` class includes properties
like `wheels`, `engineType`, and methods such as `drive`
and `park`. The `Aircraft` class includes properties like
`wingspan`, `altitude`, and methods such as `takeOff`
and `land`. The `FlyingCar` class combines these, adding
properties like `flightMode` and methods like
`switchMode` to transition between driving and flying.

2. Smartwatch from WearableDevice and Computer:


Scenario: In a tech gadget application, a `Smartwatch`
class inherits from both `WearableDevice` and
`Computer` classes. The `WearableDevice` class
includes properties like `batteryLife` and `comfortLevel`,
and methods such as `wear` and `remove`. The
`Computer` class includes properties like
`processorSpeed` and `memory`, and methods such as
`compute` and `storeData`. The `Smartwatch` class
integrates these, adding properties like
`heartRateMonitor` and methods like `trackFitness`.

3. TeachingAssistant from Student and Employee:


Scenario: In a university management system, a
`TeachingAssistant` class inherits from both `Student`
and `Employee` classes. The `Student` class includes
properties like `studentID`, `major`, and methods such
as `attendClass` and `study`. The `Employee` class
includes properties like `employeeID`, `department`,
and methods such as `work` and `attendMeeting`. The
`TeachingAssistant` class combines these, adding
properties like `assignedCourses` and methods like
`gradeAssignments`.

4. HybridAppliance from Appliance and SmartDevice:


Scenario: In a smart home ecosystem, a
`HybridAppliance` class inherits from both `Appliance`
and `SmartDevice` classes. The `Appliance` class
includes properties like `brand`, `powerUsage`, and
methods such as `turnOn` and `turnOff`. The
`SmartDevice` class includes properties like
`connectivity`, `firmwareVersion`, and methods like
`connectToWiFi` and `updateFirmware`. The
`HybridAppliance` class integrates these, adding
properties like `remoteControlCapability` and methods
like `scheduleOperation`.

5. Artist from Person and Worker:


Scenario: In a creative industry management system, an
`Artist` class inherits from both `Person` and `Worker`
classes. The `Person` class includes properties like
`name`, `age`, and `address`, and methods like
`introduce` and `move`. The `Worker` class includes
properties like `jobTitle`, `salary`, and methods such as
`work` and `takeBreak`. The `Artist` class combines
these, adding properties like `artStyle` and methods like
`createArt` and `exhibitArt`.
Here are five different scenario statements
demonstrating hybrid inheritance, which combines
two or more types of inheritance, such as single,
multiple, and multi-level inheritance within the same
hierarchy:

1. Employee, Manager, and Intern (Single and Multiple


Inheritance):
Scenario: In a company hierarchy, an `Intern` class
inherits from both an `Employee` class and a `Student`
class, while a `Manager` class inherits from the
`Employee` class. The `Employee` class includes
properties like `employeeID` and `department`, and
methods such as `work` and `report`. The `Student`
class includes properties like `studentID` and `major`,
and methods such as `study` and `takeExam`. The
`Intern` class combines these, adding properties like
`internshipDuration` and methods like
`submitInternshipReport`.
2. Shape, Polygon, Rectangle, and ColoredRectangle
(Multi-level and Multiple Inheritance):
Scenario: In a graphic design application, a
`ColoredRectangle` class inherits from both a
`Rectangle` class and a `Color` class. The `Shape` class
includes properties like `position` and `draw`. The
`Polygon` class inherits from `Shape` and adds
properties like `numberOfSides`. The `Rectangle` class
inherits from `Polygon` and includes properties like
`length` and `width`, and methods like `calculateArea`.
The `Color` class includes properties like `colorName`
and `hexValue`. The `ColoredRectangle` class combines
these, adding properties like `borderColor` and
methods like `fillColor`.

3. Appliance, KitchenAppliance, Blender, and


SmartBlender (Multi-level and Multiple Inheritance):
Scenario: In a smart home management system, a
`SmartBlender` class inherits from both a `Blender` class
and a `SmartDevice` class. The `Appliance` class includes
properties like `brand` and `powerUsage`, and methods
like `turnOn` and `turnOff`. The `KitchenAppliance` class
inherits from `Appliance` and includes properties like
`isDishwasherSafe`. The `Blender` class inherits from
`KitchenAppliance` and adds properties like `bladeSpeed`
and methods like `blend`. The `SmartDevice` class
includes properties like `connectivity` and
`firmwareVersion`, and methods like `connectToWiFi`.
The `SmartBlender` class combines these, adding
properties like `remoteControl` and methods like
`scheduleBlending`.

4. Vehicle, LandVehicle, Car, ElectricCar, and SolarCar


(Multi-level and Multiple Inheritance):
Scenario: In a transportation management system, a
`SolarCar` class inherits from both an `ElectricCar` class
and a `SolarPoweredDevice` class. The `Vehicle` class
includes properties like `make` and `model`, and
methods like `startEngine`. The `LandVehicle` class
inherits from `Vehicle` and includes properties like
`terrainCapability`. The `Car` class inherits from
`LandVehicle` and adds properties like
`numberOfDoors`. The `ElectricCar` class inherits from
`Car` and adds properties like `batteryCapacity` and
methods like `chargeBattery`. The
`SolarPoweredDevice` class includes properties like
`solarPanelEfficiency` and methods like
`harnessSolarEnergy`. The `SolarCar` class combines
these, adding properties like `solarRange` and methods
like `switchToSolarMode`.

5. Person, Athlete, Swimmer, and Triathlete (Multi-


level and Multiple Inheritance):
Scenario: In a sports management system, a `Triathlete`
class inherits from both a `Swimmer` class and a
`Cyclist` class. The `Person` class includes properties like
`name` and `age`, and methods like `introduce`. The
`Athlete` class inherits from `Person` and includes
properties like `sport` and methods like `train`. The
`Swimmer` class inherits from `Athlete` and adds
properties like `swimStyle` and methods like `swim`.
The `Cyclist` class includes properties like `bikeType`
and methods like `rideBike`. The `Triathlete` class
combines these, adding properties like
`triathlonRanking` and methods like
`competeInTriathlon`.

Here are five different scen snario statements


demonstrating hierarchical inheritance, where
multiple derived classes inherit from a single base
class:

1.Animal, Dog, Cat, and Bird:


Scenario: In a pet management system, `Dog`, `Cat`,
and `Bird` classes inherit from a common `Animal` class.
The `Animal` class includes properties like `name`, `age`,
and `species`, and methods like `eat` and `sleep`. The
`Dog` class adds properties like `breed` and methods
like `bark`. The `Cat` class includes properties like
`furColor` and methods like `meow`. The `Bird` class
introduces properties like `wingSpan` and methods like
`fly`.

2. Employee, Engineer, Salesperson, and Manager:


Scenario: In a company HR system, `Engineer`,
`Salesperson`, and `Manager` classes inherit from a
common `Employee` class. The `Employee` class
includes properties such as `employeeID`, `name`, and
`department`, and methods like `clockIn` and
`clockOut`. The `Engineer` class adds properties like
`specialization` and methods like `developSoftware`.
The `Salesperson` class includes properties like
`salesTarget` and methods like `makeSale`. The
`Manager` class adds properties like `teamSize` and
methods like `conductMeeting`.

3. Vehicle, Car, Truck, and Motorcycle:


Scenario: In a vehicle management system, `Car`,
`Truck`, and `Motorcycle` classes inherit from a
common `Vehicle` class. The `Vehicle` class includes
properties like `make`, `model`, and `year`, and
methods such as `startEngine` and `stopEngine`. The
`Car` class adds properties like `numberOfDoors` and
methods like `playRadio`. The `Truck` class includes
properties like `cargoCapacity` and methods like
`loadCargo`. The `Motorcycle` class adds properties like
`type` (cruiser, sport, etc.) and methods like
`doWheelie`.

4. Appliance, Refrigerator, WashingMachine, and


Oven:
Scenario: In a home appliance management system,
`Refrigerator`, `WashingMachine`, and `Oven` classes
inherit from a common `Appliance` class. The
`Appliance` class includes properties like `brand`,
`powerUsage`, and `status`, and methods like `turnOn`
and `turnOff`. The `Refrigerator` class adds properties
like `capacity` and methods like `setTemperature`. The
`WashingMachine` class includes properties like
`loadCapacity` and methods like `startWashCycle`. The
`Oven` class introduces properties like
`maxTemperature` and methods like `bake`.

5. Shape, Circle, Rectangle, and Triangle:


Scenario: In a graphics application, `Circle`, `Rectangle`,
and `Triangle` classes inherit from a common `Shape`
class. The `Shape` class includes properties like `color`
and `position`, and methods like `draw` and `move`. The
`Circle` class adds properties like `radius` and methods
like `calculateArea`. The `Rectangle` class includes
properties like `length` and `width`, and methods like
`calculateArea`. The `Triangle` class adds properties like
`base` and `height`, and methods like `calculateArea`.

You might also like