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

Assignment 3 (1)

The document outlines an assignment focused on Object Oriented Programming, requiring the design and implementation of class structures for account management, a shopping cart system, and a zoo animal hierarchy. It specifies the creation of classes with attributes and methods, including interest application for accounts, product billing, and animal behaviors. Students are expected to demonstrate their implementations in a main class for each scenario.

Uploaded by

balanceo450
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Assignment 3 (1)

The document outlines an assignment focused on Object Oriented Programming, requiring the design and implementation of class structures for account management, a shopping cart system, and a zoo animal hierarchy. It specifies the creation of classes with attributes and methods, including interest application for accounts, product billing, and animal behaviors. Students are expected to demonstrate their implementations in a main class for each scenario.

Uploaded by

balanceo450
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 3

OBJECT ORIENTED PROGRAMMING

CLO 2

1. Assume that the Account, BusinessAccount, and SavingAccount classes make up the inheritance
structure. The account information includes accountNo, yearOfOpening and balance. Depending
on the Account type an interest is to be applied. The interest rate on the BusinessAccount is
15%, while the interest rate on the SavingAccount is 10%. It is must for both these classes to
provide functionality for interest application.

You are required to design class diagram and implement the above scenario.

2. Prepare a program for a shop to maintain the records of its sold products by using following
concepts.
a. Product is an encapsulated class with attributes product name and its price. Include
method to return the bill of the product.
b. DiscountedProduct is also an encapsulated class that extends Product and it has an
attribute of discount. Include method to return the bill of discounted product.
c. Define a class named CustomerCart that represents a collection of multiple objects of type
Product or DiscountedProduct. The class will have an instance variable whose type is
Product[] , which will be used as a partially filled array. There will also be another instance
variable of type int that keeps track of how much of this array is currently used. Include
methods for the following:
• add a product in the cart. It can either be a product or discounted product
• display total bill
• display the number of products and discounted products in the cart individually

Create and object of CustomerCart in runner and test all functions.

3. Consider a scenario where you are designing a software system for a zoo. The zoo has various
types of animals, such as mammals, birds, and reptiles. Each type of animal has common
attributes and behaviors, but also unique ones. Design a class hierarchy using abstract classes
and inheritance to represent this scenario.
a) Create an abstract class called Animal that has the following attributes:
i) A String variable named name to store the name of the animal.
ii) An integer variable named age to store the age of the animal.

The Animal class should also have the following methods:

An abstract method called eat() that represents the eating behavior of the animal.
A non-abstract method called sleep() that prints "The animal is sleeping."
b) Create two concrete classes, Mammal and Bird, that extend the Animal class. These classes
should define their own unique attributes and behaviors. For example, the Mammal class
could have an additional attribute furColor and a method run(), while the Bird class could
have an additional attribute wingSpan and a method fly().

Implement the eat() method in both the Mammal and Bird classes. The implementation
should print "The [animal name] is eating." where [animal name] is the name of the specific
animal.

Your task is to implement the classes according to the given requirements and demonstrate their
usage in a separate Main class.

You might also like