Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ANIMAL SURVIVAL GAME Using Inheritance and polymorphism, you will create a game where the user selects and plays as one of two animals (A
ANIMAL SURVIVAL GAME Using Inheritance and polymorphism, you will create a game where the user selects and plays as one of two animals (A lion or a giraffe). The animal will have three different fields (Hunger, Thirst, and Warmth), as the player you must keep all of these fields above 0 in order to survive. Your animals stats will each by measured by an integer. Each "day" that you play every stat will decrease by 3 points. You can increase one of these stats each day by selecting one of three options: 1. Hunt for food 2. Search for Water 3. Stay in shelter Each option functions slightly differently in the way that it increases your stat, as will be further below. The following is an example for how your program might look: run: Welcome to the animal survival game! Choose one of the following animals to play as... You will need to keep your hunger, thirst, and warmth levels high enough to survive! Who would you like to play as: 1. Lion 2. Giraffe 1 DAY 1 ANIMAL: LION HUNGER: 12/15 DAY 4 ANIMAL: LION HUNGER: 3/15 THIRST: 10/15 WARMTH: 16/20 What would you like to do? 1. Hunt for food 2. Search for water 3. Find Shelter 2 Your thirst has replenished by 8 points THIRST: 12/15 WARMTH: 17/20 What would you like to do? 1. Hunt for food 2. Search for water 3. Find Shelter 1 Unfortunately you did not find any food... another day going hungry DAY 2 ANIMAL: LION HUNGER: 9/15 DAY 5 ANIMAL: LION HUNGER: 0/15 THIRST: 15/15 WARMTH: 13/20 You have died! You survived for 5days. BUILD SUCCESSFUL (total time: 20 seconds) THIRST: 9/15 WARMTH: 14/20 What would you like to do? 1. Hunt for food 2. Search for water 3. Find Shelter Your thirst has replenished by 7 points DAY 3 ANIMAL: LION HUNGER: 6/15 THIRST: 13/15 MARMTH: 11/20 What would you like to do? 1. Hunt for food 2. Search for water 3. Find Shelter 3 You stayed in your den and warmed up today, your warmth has increased by 8 CHAIN OF INHERITANCE 1. Create an Animal class which both Lion and Giraffe will inherit from. This superclass will contain fields for hunger, thirst, and warmth, as well as all of the appropriate constructor, getters and setters. 2. It is not essential for your Lion and Giraffe classes to have any fields. However, the following are methods that you might want to consider creating for an efficient program: a. Menu() - This method will first provide a status update of your animal by calling upon your toString(). It will then provide the menu, prompting them to select one of three options: Hunt for food, Search for water, or Stay in shelter. Depending on what the user selects your program will send them to the appropriate method. b. toString(this method will print out an update of your animals stats, for example: ANIMAL: LION HUNGER: 9/15 THIRST: 9/15 WARMTH: 14/20 C. findFood()- wwwwwwwwd i. Lion - 50% chance to fully replenish the hunger, 50% for nothing to happen ii. Giraffe - 10% chance that they have been hunted by a lion (decrease hunger, water, and warmth by 1), 90% chance to increase hunger by a random number between 6 and 11 d. findWater() - i. Lion - 75% chance to increase thirst by 8, 25% chance that they found a campsite and raided it (increasing hunger, water, and warmth to its maximum amount) ii. Giraffe - increase thirst by 12, decrease warmth by 2 e. findWarmth() i. Lion - Increase warmth by a random number between 6 and 11 Giraffe - Increase warmth by 8 ii. MAIN METHOD 1. Create a reference variable of data type Animal. Using polymorphism, ask the user what animal they would like to play as and assign that object to your reference variable. 2. Repeatedly call upon your object's Menu() method until the user loses. The user loses when any one field reaches 0. 3. Do not let any field equal more than the maximum value! HAVE EXTRA TIME? - MAKE YOUR PROGRAM UNIQUE After creating the above program, you could take some time to make your game more complicated, unique, and fun to play! The following are some suggestions for features you can add to your program. You don't have to use my ideas, make up your own features if you are feeling creative! Remember, implementing effective forms of randomization and chance are what make games fun and ceptaxable Alter the maximum hunger/thirst/warmth depending on the animal the user picks to make them more unique. Add more animal subclasses! Ex. You can make a fish subclass whose thirst will never be reduced from its max stat. Expand your menu! Add more actions for the user to choose, for example... Create an extra field in Lion subclass called pace (initialized to 1 through your constructor). This describes how many lions are travelling in your pack. The more lions that are in your pack, the higher the chance of success when you are hunting for food. Provide a fourth option in the Lion's menu which allows him to increase his pack size instead of replenishing hunger/thirst/warmth that day. Provide checkpoints as positive reinforcement for the user (ie if you are a lion and reach day 10, Prompt them that they have become the head of their Lion pack). Remember- providing a false sense of progress will keep your users engaged and wanting to keep playing!
Step by Step Solution
★★★★★
3.40 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
This Java program implements the animal survival game as described with inheritance polymorphism and the specified behaviors for each animal import javautilRandom import javautilScanner class Animal p...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started