Question: The PetShow program should tell a short animated story using Animal objects. The story consists of 3 animals ( randomly situated ) , that performs
The PetShow program should tell a short animated story using Animal objects. The story consists of animals randomly situated that performs the same "welcome" routine. Then the left and right most animals will compete towards their respective exit the closest to them The animation stops when one of them has crossed their respective exit line. The animal that is horizontally in the middle remains still.
petshowactions.png
tip You do not have to draw the vertical lines.
You have methods to write
closestToLeft which returns the animal closest to the left of the Graphic Pane
closestToRight which returns the animal closest to the right of the Graphic Pane
routine which makes the animal perform some routine. The routine can be as simple as "introducing itself, going left, jumping, going right, speaking". Try to use a mix of methods from the Animal class. You can be as creative as you want. You will need to think about what parameters the routine method needs to have.
animate that animate the whole story.
Instructions and Tips
You must use the EXITLEFT, EXITRIGHT, STARTLEFT, and STARTRIGHT constants.
The animals must be initially randomly placed horizontally between STARTLEFT and STARTRIGHT.
You may choose their vertical position.
The animate method must call the routine, closestToLeft, and closestToRight methods with the right parameters.
Use a while loop to move the animals towards their goal line.
Run the demo program to see what your program should do You can adapt the routine to your liking, but must follow the structure of the story.
You should also look at the documentation version of Animal.java to find out the parameters of the constructor and the names and parameters of the methods in the Animal class. Open Animal.java in the BlueJ editor and select the "documentation" option.
The Animal class has already been written for you and includes various methods such as goLeft, goRight, jump, speak etc.
tip Note that there are several possible images you can use for your animals. The first argument to the Animal constructor must be the name of an image in the animals folder. There are several images called "bird", "dinosaur", "dog", "grasshopper", "snake", "tiger", and "turtle" in the download folder, but you can make your own if you wish. They must be gif files. Remember to submit them!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
