![]() How many of the Cat's methods return a value?ħ. How many methods does the class Cat have?Ħ. Make sure that the editor is in Documentation view. Download the scenario here and open it in Greenfoot before continuing.ĥ. Write another method call for the "addAmount" method from exercise 1.Īll the following exercises are intended to be implemented in the Greenfoot scenario "fatcat". On paper, write a method call (note: this is a method call, not a signature) for the "play" method from exercise 1. The method has a parameter of type "int" that is called "number", and it returns a value of type "int".Ĥ. Write a method signature for a method named "process". The method has no parameters, and it does not return a value.ģ. Write a method signature for a method named "go". How many parameters does the method haveĢ.Does the method return a value? If yes, what is the type of the return value?.Look at the following method signatures: public void play() public void addAmount(int amount) public boolean hasWings() public void compare(int x, int y, int z) public boolean isGreater (int number) įor each of these signatures, answer the fllowing questions: Verifies whether a the cat can see the pizza and returns a Yes / No respectively.Ĭhecks to see if you can see pizza.1. If the right button and left button is not pressed, then Change picture cat sitting. If the left button is pressed on the keyboard, replace the image walking to the left one using the two images cat_walk_left and cat_walk_left2 Set new horizontal position to the right. If the right button is pressed on the keyboard, replace the image of walking to the right one, using the two images cat_walk_right and cat_walk_right2 Left and right movement while changing the pictures. If an pizza object is eaten delete it and then replaced the image. For example: private GreenfootImage cat_sit Ĭat_sit = new GreenfootImage ("cat-sit.png") Įvery time the pizza is eaten show the images of a cat eating and then sitting. After Finishing eating it just sits and waits for a keyboard command.Ĭonstructor, the object whose job is to build a cat.Ĭreate a series of global variables of type GreenfootImage above this method. Then it performs a series of pictures to show. If your cat meets a pizza, a cat eats it and deletes the distributed object from the world. The cat will move back and forth with images changing.Ģ. The cat goes to the left 1 – cat-walk-left.png The cat goes dress 2 - cat-walk-left2.png The cat goes right 1 - cat-walk-right.png The cat goes right 2 - cat-walk-right2.png Cat food 1 - cat-eat.pngġ. Within the scenario directory there are several pictures which helped. After he finished eating, he can continue to move. ![]() Once the cat and the Pizza Triangle meets, he sits and eats. Use the two images to make it look like walking. Our cat can move only right and left (horizontal axis) using the keyboard. This class defines the role cat behavior. Hints: Greenfoot.getRandomNumber addObject() Add a new slice of pizza with a random chance of 2%. The builder also adds to the world the new cat location (45,450). X is given a random location on the axis. ![]() To remove the pizzas being added to the world with a chance of 2% - from the top of Y axis at the position 0. This class defines the role of the world scenario and add objects.ģ. This method looks all the time that the software performs so it's like an infinite loop GetWorld () getHeight () removeObject (this)Ĭall these two methods one after the other. The pizza will be removed if it hits the edge of the World. Sometimes the pizza will move slightly left and right horizontally. Delete the object after leaving the scope of the world. Falling pizza will a swivel on a central axis.Ģ. After reaching the lower edge of the screen, it disappears from the world.ġ. The pizza is falling toward the floor, with rotation about the central axis to give the feeling of a fall. The instructions here are designed to help you with the steps to program the game. The game sounds simple but requires programming effort and investment. When the time runs out, end the game and displayed the number of pizza slices eaten. Once the cat finishes eating cat should continue to try and catch more pizza within a certain time. Once your cat is catching the pizza it begins to eat. You're using the keyboard to control moving the cat left and right. How's the game works: Pizzas begin to fall from the sky. ![]() Objective: Build a computer game with FatCat I really, really need help to do this!! please!!.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |