Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am in dire need of help. I can't seem to figure this out and nobody has been able to help me. Program is java

I am in dire need of help. I can't seem to figure this out and nobody has been able to help me. Program is java based and used in greenfoot. The skeleton code below instructions is the only thing that needs to be filled thanks.

image text in transcribed

image text in transcribed

import greenfoot.*;

/** * * */

public class Ball extends Actor

{ /** * Responds to motion control from the arrow keys and removes * any buttons from the world when it intersects them. */ public void act() {

}

/** * Checks to see if the ball is "touching" an object of the Button class. * If it is, then the ball removes from the World a Button that it touches. * If the ball isn't touching an object of the Button class, then this * method does nothing. */ public void lookForButton() {

}

/** * Handles input from the arrow keys. */ public void handleKeyPress() {

}

/** * Checks to see if the left arrow key is being pressed. * If it is, then the ball sets its rotation angle to zero degrees * and moves backward 5 units. If it is not being pressed, * this method does nothing. */ public void checkLeftArrow() {

}

/** * Checks to see if the right arrow key is being pressed. * If it is, then the ball sets its rotation angle to zero degrees * and moves forward 5 units. If it is not being pressed, * this method does nothing. */ public void checkRightArrow() {

}

/** * Checks to see if the up arrow key is being pressed. * If it is, then the ball sets its rotation angle to 270 degrees * and moves forward 5 units. If it is not being pressed, * this method does nothing. */ public void checkUpArrow() {

}

/** * Checks to see if the down arrow key is being pressed. * If it is, then the ball sets its rotation angle to 90 degrees * and moves forward 5 units. If it is not being pressed, * this method does nothing. */ public void checkDownArrow() {

} }

public class Button extends Actor { /** * Changes the location of this button approximately * 2% of the time. */ public void act() { } /** * Sets the location of this Button object to a new (x, y) * coordinate selected at random. The x coordinate wil be in * the range 100 to 500 inclusive, and the y coordinate will * be the range 100 to 300 inclusive. */ public void changeLocation() { } }

Writing methods for the Batt class 1. Write the body of the act() method of the Ball class The act method simply calls the following methods in the order specified below 1. handleKeyPress 2. lookForButton 2. Write the body of the handleKeyPress() method of the Ball class The handleKeyPress method simply calls the following methods in the order specified below 1. checkLeftArrow 2. checkRightArrow 3. checkUpArrow 4. checkDownArrow 3. Write the body of the checkLeftArrow) method of the Ball class This method checks to see if the left arrow key is being pressed. If it is, then the ball sets its rotation angle to zero degrees and moves backward 5 units. If it is not being pressed, this method does nothing. List of methods to use o Greenfoot.isKeyDown o setRotation o move 4. Write the body of the checkRightArrow() method of the Ball class This method checks to see if the right arrow key is being pressed. If it is, then the ball sets its rotation angle to zero degrees and moves forward 5 units. If it is not being pressed this method does nothing. List of methods to use o Greenfoot.isKeyDown o setRotation O move

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_2

Step: 3

blur-text-image_3

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

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions

Question

Briefly describe MRP II and closed- loop MRP.

Answered: 1 week ago