Description
Create an interactive pet game where the user has life points and interacts with different
types of cats. Create your classes based on the following class diagram:
Method Descriptions:
1. incrementHunger(int val) – passes in the amount to modify the cat’s hunger level
(hunger level is always 1-10, where 1 is most hungry, and 10 is full). Positive for
feeding the cat, negative for the cat becoming hungrier. After modifying the
value, check to be sure that the hunger level is always between 1-10. If not,
adjust the value (ex. if hunger is -3, reset it to 1, if it is 11, reset it to 10).
2. feed(Player p) – passes in the player feeding the cat. If the cat is hungry, they will
eat the food. If they are full, then the cat will attack the user (call takeDamage
with the amount of damage). Return a string representing the interaction.
3. play(Player p) – passes in the player playing with the cat. If the cat is very
hungry, then it will attack the player. Playing with the cat will make the cat’s
hunger level go up. Come up with other things the cat will do at different hunger
levels. Return a string representing the interaction.
4. pet(Player p) – passes in the player petting the cat. If the cat is hungry, it will
attack the user. If the cat is full, it will purr and fall asleep. Return a string
representing the interaction.
5. takeDamage(int d) – decreases the player’s hp by amount d.
6. interactCat(Cat c, Player p) – displays the player and cat. Displays the cat
interaction menu, get’s the user’s input, and calls the corresponding cat method
and displays the string returned from the interaction.
Create a Main that displays a menu for each of the three cat types and get’s the user’s
choice and the name of the cat. Construct a Player and a Cat of their choice. Repeatedly
call interactCat until the user dies.
Example Output:
Choose a kitty:
1. Tabby Cat
2. Ocelot
3. Tiger
1
Name your kitty: Fluffy
You have 10/10 HP
Fluffy is hungry
1. Feed your cat
2. Play with your cat
3. Pet your cat
1
Fluffy is pretty hungry, and starts chomping down the food right away.
You have 10/10 HP
Fluffy is full
1. Feed your cat
2. Play with your cat
3. Pet your cat
1
Fluffy is already full, and bites and scratches you for insulting them
with food. You take 2 damage.
You have 8/10 HP
Fluffy is full
1. Feed your cat
2. Play with your cat
3. Pet your cat
2
Fluffy is so full, they can barely roll over to glare at you when you
roll a jingle ball toward them.
You have 8/10 HP
Fluffy is satisfied
1. Feed your cat
2. Play with your cat
3. Pet your cat
3
Fluffy happily allows you to pet them.
You have 8/10 HP
Fluffy is satisfied
1. Feed your cat
2. Play with your cat
3. Pet your cat
2
Fluffy jumps and plays with the string you dangle in front of them.
Fluffy accidentally scratches you for 1 damage.
You have 7/10 HP
Fluffy is hungry
1. Feed your cat
2. Play with your cat
3. Pet your cat
…