Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART IIT FREE RESPONSE QUESTION 1) The Bunny Bop class models a bunny hopping around a two dimensionat board, where each index in the board

image text in transcribed
image text in transcribed
PART IIT FREE RESPONSE QUESTION 1) The Bunny Bop class models a bunny hopping around a two dimensionat board, where each index in the board either han or does not have food represented by an integer value). public clase Bunnyliop private int board: private int rowPOR? private int colos private boolean happy publie BunnyHop(int row, int cola) 1. code not shown / public void hop /* code mot shown / a) The BunnyHop constructor is intended to initialize the board. Each Index should have a 60chance of having food (denoted by the integer value 1) and 40$ chance of tot having food denoted by the Integer value 0). The bunny position, denoted by rowon and colpos, should also be initiated to a random value (within the boundaries of the board's nine), and the bunny should start out happy. Write the code for the Bunnyttop constructor below. b) The hop method is intended to simulate a "hop to a random spot on the board. If that spot contains food, the bunny will be happy, the food at that spot should be eaten, and the message: "Happy bunny!" should be printed. Otherwise, the frog will be unhappy (false) and the message "Hungry bunny." should be printed. Write the code for the hop method. c) The Frog Hop class extends the BunnyHop class. It also has an extra variable denoting the frog's eye color (a string). In order for the frog to be happy in its hop method, in addition to the space having food, there must be at least 2 other spaces in the same row or column that have food in them. Write the code for the ProgHop class. PART IIT FREE RESPONSE QUESTION 1) The Bunny Bop class models a bunny hopping around a two dimensionat board, where each index in the board either han or does not have food represented by an integer value). public clase Bunnyliop private int board: private int rowPOR? private int colos private boolean happy publie BunnyHop(int row, int cola) 1. code not shown / public void hop /* code mot shown / a) The BunnyHop constructor is intended to initialize the board. Each Index should have a 60chance of having food (denoted by the integer value 1) and 40$ chance of tot having food denoted by the Integer value 0). The bunny position, denoted by rowon and colpos, should also be initiated to a random value (within the boundaries of the board's nine), and the bunny should start out happy. Write the code for the Bunnyttop constructor below. b) The hop method is intended to simulate a "hop to a random spot on the board. If that spot contains food, the bunny will be happy, the food at that spot should be eaten, and the message: "Happy bunny!" should be printed. Otherwise, the frog will be unhappy (false) and the message "Hungry bunny." should be printed. Write the code for the hop method. c) The Frog Hop class extends the BunnyHop class. It also has an extra variable denoting the frog's eye color (a string). In order for the frog to be happy in its hop method, in addition to the space having food, there must be at least 2 other spaces in the same row or column that have food in them. Write the code for the ProgHop class

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

10-17 Could Nasty Gal have avoided bankruptcy? Explain your answer.

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago