Professional Documents
Culture Documents
QUESTION 2 (20 Marks) : Confidential 3
QUESTION 2 (20 Marks) : Confidential 3
You have been tasked with developing an animal shelter management system for a local
animal shelter. The shelter needs a system to manage their animals, including name, age,
breed (eg: Belgian Shepherd) and availability for adoption.
a) Write a complete class definition for the object you identified in the above problem that
contains all attributes as mentioned above and the following methods.
A normal constructor.
Accessor methods for data members.
A setAvailability(boolean available) method that receives a boolean value
and modifies the availability for adoption.
An isAvailable() method that determines the availability for adoption by returning
true for available. Otherwise, it returns false.
A toString() method that returns all data members of the class.
(10 marks)
name - "Lucky"
age - 2
breed - "Labrador Retriever"
(2 marks)
name - "Milo"
age – 1
breed - "German Shepherd"
(2 marks)
v) Count and display the number of animals available for adoption in the shelter.
(2 marks)
vi) Calculate and display the average age of all animals in the shelter.
(2 marks)