ANIMAL SURVIVAL GAME Using Inheritance and polymorphism, you will create a game where the user selects...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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! 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!
Expert Answer:
Answer rating: 100% (QA)
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... View the full answer
Related Book For
Practicing Statistics Guided Investigations For The Second Course
ISBN: 9780321586018
1st Edition
Authors: Shonda Kuiper, Jeff Sklar
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Before you begin this assignment, be sure you have read the UMUC Family Clinic Case Study below and your Week 1 and Week2 syllabus readings, which discuss EHR functionality and Process...
-
What is opportunity cost? explain a time in your life when you experienced opportunity cost. Why did you make the decision? What was another alternative that you could have made? Discuss how scarcity...
-
The job offer process is very critical when choosing the best candidate for the job. Some of the things that attract and entice candidates were mentioned in previous units. As with strategies for...
-
The magnetic circuit of figure consists of a core and a moveable plunger of width l p , each of permeability ?. The core has cross-sectional area A and means length A c . The overlap area of the two...
-
AMS Company has unexpectedly generated a one-time extra \($5\) million in cash-flow this year. After announcing the extra cash flow, AMS stock price was \($55\) per share (it has 1 million shares...
-
The following table lists the components needed to assemble an end item, lead times, and quantities on hand. a. If 20 units of the end item are to be assembled, how many additional units of E are...
-
1 2 Part 2 of 15 points Skipped eBook P Deferences Required information The Foundational 15 (Algo) [LO14-2, LO14-3, LO14-4, LO14-5, LO14-6] [The following information applies to the questions...
-
Matt Simpson owns and operates Quality Craft Rentals, which offers canoe rentals and shuttle service on the Nantahala River. Customers can rent canoes at one station, enter the river there, and exit...
-
In January 2022, the manager of a construction firm known as FENEST TC decided to measure the performance of the staff of the firm. This initiative was meant to measure the success of series of...
-
What is the current state of Public Broadcasting in the Philippines. Explain your answer thoroughly
-
Using the accounts receivable method, Jurasic Pork, Inc., estimates that $4,000 of its receivables will not be collected as of year end. Prior to adjustment, the Allowance for Doubtful Accounts has a...
-
1. Given f(x)=- x +3x + 2x x + x-2 complete the following: a. Write the rational expression in lowest terms, leaving it in factored form. (6 points) b. Write the domain in interval notation. (6...
-
What are three abilities in negotiation? Which one is the most important ability to apply during the negotiation full of hoax? Please provide reasons as well as examples to support
-
The type of pricing policy that takes the amount it cost you to make the product and increments that amount by a set percentage to determine the final price,what is this called and how is it working?
-
Suppose Bills and Brothers Co. and Sally and Sisters ltd are bargaining over the wages W at which Sally will perform a one-week computer programming service for Bill who is about to start an internet...
-
Nike manufactures shoes and sportswear. How has the Internet changed the way this company communicates with its suppliers and retail customers?
-
Assume that no censoring is present in the melting times (see the entries in Table 9.1). Estimate S(25), S(30), S(45), and S(55) using both the empirical survival function and the Kaplan-Meier...
-
Create a graph of the logarithm of the cancer incidence rates versus the median of the age group by location. Describe the relationship between age and cancer rate separately for the CTR data and the...
-
Provide interpretations of the Bayesian credible interval you constructed in Question 41 and the confidence interval you constructed in Question 42. Which interpretation seems more natural to you?
-
The coloring of the blue morpho butterfly is protective. As the butterfly flaps its wings, the angle at which light strikes the wings changes. This causes the butterfly's color to change and makes it...
-
In the laser range-finding experiments of Example 17.10, the laser beam fired toward the moon spreads out as it travels because it diffracts through a circular exit as it leaves the laser. In order...
-
The change in color when acetone is placed on the wing is due to the difference between the indices of refraction of ace- tone and air. Consider light of some particular color. In acetone, A. The...
Study smarter with the SolutionInn App