ACE Computer Training Center Using Operators to Move Objects Project

User Generated

cybqyrr1

Programming

ACE Computer Training Center

Description

Unformatted Attachment Preview

Using Operators to Move Objects Open the FlyingBird_Lesson2 program. Use save as and resave the program as FlyingBird_Lesson3. In the FlyingBird_Lesson3 program do the following: Add the methods and variables as indicated below. Part 1: Open the editor for the Bird1 class and create the following variables and methods. Name of Method Purpose public void applyGravity() This method will simulate gravity causing the bird to fall. Use the bird’s current x and increment the Y using the velocity variable. Variables needed velocity gravity Part 1: ACTIVITIES TO DO – Complete the following 1-4 activities 1) Open the source code editor for the Bird1 and create the global instance variable for velocity and the class variable for gravity in the field area.   velocity is a double, private variable, set it to 0 Gravity is a static final double private variable, set it to 0.5 2) Under the act method, Create the method header for the applyGravity() method. It will be public and void. This method has two statements. a) Use the setLocation(int x, int y) method and write a statement that will get the current x and y for the bird and add the velocity variable to the Y coordinate. b) Write an expression that will update the velocity variable by adding the gravity variable to it. 3) Add the applyGravity() method to the act() method to call it. 4) Test to see if the bird falls. Debug if needed. Turning It In Using Operators to Move Objects Create a zip file called Using_Operators_To_Move_Objects and place the entire FlyingBird_Lesson3 Greenfoot folder in it. Turn in the zip file to the Using Operators to Move Objects assignment.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.For this assignment, ...


Anonymous
Just what I needed. Studypool is a lifesaver!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags