0% found this document useful (0 votes)
18 views2 pages

Lab 02

The document outlines a lab task for developing a Pet Adoption and Care System using object-oriented design principles. It specifies the attributes and methods for Pet and User classes, including functionalities for adopting and caring for pets. Additionally, it describes the PACS class that manages users and pets, including methods for registering users and pets, and facilitating random pet adoption.

Uploaded by

esin tan
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)
18 views2 pages

Lab 02

The document outlines a lab task for developing a Pet Adoption and Care System using object-oriented design principles. It specifies the attributes and methods for Pet and User classes, including functionalities for adopting and caring for pets. Additionally, it describes the PACS class that manages users and pets, including methods for registering users and pets, and facilitating random pet adoption.

Uploaded by

esin tan
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

SE 116 Introduction to Programming II

Lab No: 02

Topic: OO Design Principles

TASK 1:
In this lab, you are responsible for developing a Pet Adoption and Care System.
In this system, there are pets and users that will interact with each other.
Each pet has its name, hungerLevel, happinessLevel, owner as class fields.
You will determine the data types of these attributes. (hungerLevel and
happinessLevel is bounded between 0-100)
Pet class will have accessor(getter) and mutators(setter) methods for all class fields also
implement parameterized constructor that will assign corresponding Pet’s name,
hungerLevel, happinessLevel to same values except owner, initiliaze the owner
attribute to a default value as null.
Pet class will have the following methods;
eat(); : This method will decrease the corresponding pet’s hungerLevel by 10 unit.
play(); This method will increase the corresponding pet’s happinessLevel by 5 unit.
checkStatus(); : This method will display the current hungerLevel and
happinessLevel of a pet.

Each user has its name and a list of adoptedPets as class fields. You will determine the
data types of these attributes.
User class will have accessor(getter) and mutators(setter) methods for all class fields also
implement parameterized constructor that will assign corresponding User’s name to same
value except adoptedPets, initiliaze the adoptedPets attribute to a default value as
empty list. (Use Java’s Collection Lists)

User class will have the following methods;


adoptPet(Pet pet); : This method will add the corresponding pet into adoptedPets list.
carePet(String petName); : This method will allow user to feed and play with the given pet.

PACS (Pet Adoption and Care System) has the list of users and pets as class fields.
This class will have a default constructor that will initiliaze the lists above as empty. Also this
class will have the following functionalities;
registerUser(User user); : This method registers the corresponding user into system.
registerPet(Pet pet); : This method registers the corresponding pet into system.
adoptRandomPetFromSystem(); : This method will print whole registered users and you will
select one of them and the system randomly selects one of the pets in the system and this user
will adopt that randomly selected automatically. (Don’t forget to remove that randomly
selected pet from system.).

Create some user objects and pet objects register them into PACS, and try each functionality
one by one in your main.

You might also like