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

Lab 9

The document outlines five programming tasks that involve creating systems using polymorphism in object-oriented design. Each task includes a base class and specific subclasses that override methods to implement unique behaviors for geometric shapes, menu items, animals, employees, and bank accounts. The focus is on utilizing inheritance and method overriding to customize functionality for different categories within each system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab 9

The document outlines five programming tasks that involve creating systems using polymorphism in object-oriented design. Each task includes a base class and specific subclasses that override methods to implement unique behaviors for geometric shapes, menu items, animals, employees, and bank accounts. The focus is on utilizing inheritance and method overriding to customize functionality for different categories within each system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 9 CLO 5

Question: 1
• Task: Create a geometric calculator that performs calculations on different geometric
shapes such as area and perimeter.

• Scenario: Utilize polymorphism by designing a base class GeometricShape with


methods like calculateArea() and calculatePerimeter(). Subclass this base class to
create specific shape classes like Circle, Rectangle, and Triangle, each overriding the
calculateArea() and calculatePerimeter() methods to compute the values specific to
that shape.

Question: 2
• Task: Create a system for managing menus in a restaurant with different categories like
appetizers, main courses, and desserts.

• Scenario: Define a base class MenuItem with methods like displayDescription() to


show the details of a menu item. Subclass this base class to represent specific
categories such as Appetizer, MainCourse, and Dessert. Override the
displayDescription() method in each subclass to provide customized formatting or
additional information specific to the category of menu item.

Question: 3
• Task: Develop a simulation program for an animal kingdom where different types of
animals exhibit various behaviors.

• Scenario: Implement polymorphism by designing a base class Animal with methods like
eat() and move(). Create subclasses such as Lion, Elephant, and Snake, each
overriding the eat() and move() methods to reflect the unique behavior of that animal
type.

Question: 4
• Task: Create a payroll system for a company that handles payments for different types of
employees including full-time, part-time, and contract workers.

• Scenario: Utilize polymorphism by defining a base class Employee with common


attributes and methods such as calculatePay(). Then, derive subclasses like
FullTimeEmployee, PartTimeEmployee, and ContractEmployee, each implementing
its own version of the calculatePay() method based on the specific payment rules for
that type of employee.

Question: 5
• Task: Implement a system for managing bank accounts with different types such as
savings and checking accounts.

• Scenario: Create a base class Account with methods like withdraw() and deposit().
Subclass this base class to define specific account types like SavingsAccount and
CheckingAccount. Override the withdraw() method in each subclass to implement
specific withdrawal rules, such as minimum balance constraints for savings accounts
and overdraft protection for checking accounts.

You might also like