Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code a Java program to create the following game. This is a game of 4 questions (not 20). The object of the game is to

Code a Java program to create the following game.

This is a game of 4 questions (not 20). The object of the game is to determine what type of animal you are, (Rabbit, Dog, Fish or Turtle). Inputs

Ask the player the following four yes/no questions and save the user's answers in variables.

  • Do you swim? yes - no
  • Do you have fins? yes - no
  • Do you bark? yes - no
  • Do you growl? yes - no

Use confirm Dialog Boxes to get the yes/no answers from the user.

Add a loop to continue playing the game.

Stop when the user wants to stop.

Count how many times the user played the game.

Use the abbreviated incrementor to do this.

Processing

You MUST use AND OR and NOT to complete this exercise. You MUST use the following assumptions to determine the animal.

Animals that swim AND have fins are fish Animals that can bark OR growl are dogs Animals that do NOT swim are rabbits Animals that swim but do NOT have fins AND do NOT bark are turtles Outputs

When you figure out what animal it is, have the animal say "Oh, that is me. I am a .............."

At the end, output Programmed by: your name

Comment your code, as always.

Phase 2 - Required

Write and execute at least one method. This method MUST be written by you (not a Java predefined method).

Add logic to allow the user to play the game again.

Count the number of times the user has played the game.

Phase 3 - Required - Research Challenge

  • Display an image of each animal when you figure out which animal it is.
  • Use the following names for your image files
    • rabbit.jpg
    • fish.jpg
    • dog.jpg
    • turtle.jpg

Sample Run Welcome to What Animal am I ?.

Do you swim? yes/no YES

Do you have fins? yes/no YES

Do you bark? yes/no NO

Do you growl? yes/no NO

------------------------------- Ahhh, I see, you are FISH Do you want to play again? Yes/no NO

You played the game 1 time.

Thanks for playing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions