Question: Please help required skeleton code is below. /** * Write a description of class PigWorld here. * */ public class PigWorld extends World { /**

Please help required skeleton code is below.

Please help required skeleton code is below. /** * Write a descriptionof class PigWorld here. * */ public class PigWorld extends World {/** * Builds a PigWorld object. * */ public PigWorld() { super(600,

/** * Write a description of class PigWorld here. * */ public class PigWorld extends World {

/** * Builds a PigWorld object. * */ public PigWorld() { super(600, 400, 1, false); setPaintOrder(Pig.class, Mushroom.class); addObject(new Pig(), 400, 300); } /** * Adds mushrooms at the top of the screen at given intervals. */ public void act() { if (Greenfoot.getRandomNumber(100)

/** * Write a description of class Mushroom here. * */ public class Mushroom extends Actor { /** * Moves one unit down the screen each act cycle. * Stops the scenario if this mushroom reaches the bottom * of the screen. */ public void act() { setLocation(getX(), getY() + 1); if (getY() == 400) { Greenfoot.stop(); } } }

import java.util.List;

/** * Write a description of class Barrel here. * */ public class Barrel extends Actor { /** * Automatically called by Greenfoot whenever a Barrel object * is placed in a world. In this assigment, we use it to remember * the initial state of this barrel - its (x,y) position and its * original image size. */ public void addedToWorld(World world) { } /** * Returns how many mushrooms this barrel has stored. */ public int getMushrooms() { return 0; // change this! } /** * Follows mouse drag-and-drop motion. Eats nearby mushrooms when * dropped and increases its current image scale by 25%. If this barrel * stores more than 10 mushrooms, this barrel has itself removed from * this world. */ public void act() {

} /** * Returns this barrel to its original (x,y) location and its * original image scale. */ public void reset() { } }

/** * Write a description of class Pig here. * */ public class Pig extends Actor { /** Keeps track of how many mushrooms this pig has eaten. */ private int shrooms; /** * Constructs a Pig object and initializes it as having * eaten no mushrooms. */ public Pig() { shrooms = 0; } /** * Follows the mouse movement and eats mushrooms on mouse clicks. * Stops the scenario once this pig has eaten at least 15 mushrooms. */ public void act() { if (Greenfoot.mouseMoved(null)) { MouseInfo mouse = Greenfoot.getMouseInfo(); setLocation(mouse.getX(), mouse.getY()); } if (Greenfoot.mouseClicked(null)) { Mushroom m = (Mushroom) getOneIntersectingObject(Mushroom.class); if (m != null) { shrooms++; getWorld().removeObject(m); } } if (shrooms > 14) { Greenfoot.stop(); } } }

1. Make the pig win the game after eating at least 30 mushrooms. (It's currently set to win at 15.) This will involve the act method in the Pig class. Add one Barrel object at location (565, 350) in the world. This will involve the constructor of the Pigworld class. 3. Allow the user to drag-and-drop the barrel anywhere in the world by using the mouse. This will involve the act method of the Barrel class. 4. When the barrel is dropped, make all the mushrooms within a 75-unit radius become "stored" in the barrel. (Make sure that the mushrooms disappear from the world. The barrel doesn't store Hushroom objects at all instead, it only keeps a count of how many it has "stored".) This will involve the act method of the Barrel class. 1. Make the pig win the game after eating at least 30 mushrooms. (It's currently set to win at 15.) This will involve the act method in the Pig class. Add one Barrel object at location (565, 350) in the world. This will involve the constructor of the Pigworld class. 3. Allow the user to drag-and-drop the barrel anywhere in the world by using the mouse. This will involve the act method of the Barrel class. 4. When the barrel is dropped, make all the mushrooms within a 75-unit radius become "stored" in the barrel. (Make sure that the mushrooms disappear from the world. The barrel doesn't store Hushroom objects at all instead, it only keeps a count of how many it has "stored".) This will involve the act method of the Barrel class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!