subject

Ineed writing a prgram for a crab the current code is posted below the question.1. double-click on the crab class in the greenfoot class diagram to open the class in an editor window. write the body of the turnleft() method in the crab class. this method causes a crab to turn/rotate 90 degrees to its left (i. e., with respect to its current orientation).be sure to test the turnleft() method before proceeding to the next step.2.write the body of the backup() method in the crab class. this method causes a crab to "back up" (move backwards) the indicated distance with respect to its current orientation. the crab’s orientation must not change. for example, the method call backup(50) would cause the crab to move backwards 50 units. be sure to test the backup() method before proceeding to the next step.3.write the body of the act() method in the crab class. this method defines the following behavior for a crab: first, the crab moves forward distance 5. then, the crab checks to see if it is at an edge of the world. if it is, the crab moves backwards 50 units using the backup() method and then turns to its left using the turnleft()method. be sure to test the act() method before proceeding to the next step.4. challenge: the crab is walking straight into the gull, which is probably not a good idea (links to an external site.)links to an external site.. let’s the crab out by changing the act() method to ensure that the crab walks below the gull when it makes the trip across the top of the screen. specifically, you need implement the following behavior in the act() method: first, the crab moves forward distance 5. then, the crab checks to see if it is at an edge of the world. if it is, the crab then checks to see if it’s the top edge. if it is the top edge, the crab moves backwards 150 units using the backup()method. no matter which edge it is at, the crab then moves backwards 50 units using the backup() method and then turns to its left using the turnleft() method. to do this, you will have to search through the documentation of the actor class to find a method that will allow you to detect when the crab is at the top edge of the world. once you find the method you need to use, the hints below should you put this all together. you will need to add another if statement inside the one you already have. you can ask if two int values are equal by using the == operator. (this is two equal signs with no space in between.) here are some examples: 5 == 5 evalutes to true3 == 5 evaluates to falselet’s say there is a method m() that returns an int value. then you can check if this method returns a particular value like this: if (m() == 5).crab code below: import greenfoot.*; /*** this class defines a crab. crabs live on the beach.*/public class crab extends actor{public void act(){} /** turns the crab to face left from its current perspective. */public void turnleft() { } /** moves the crab backwards the given distance. */public void backup(int distance) { }}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 05:20, jaylenmiller437
Which operating system is a version of linux?
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, ranmmm
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
image
Computers and Technology, 23.06.2019 21:20, FlowerChild1229
For positive constants a and b, the force between two atoms in a molecule is given f(r) = −a r2 + b r3 , where r > 0 is the distance between the atoms. note: a and b are upper case letters. (a) find f '(r) = (b) find the critical point for f(r). r = (c) find f ''(r) = (d) find the value of r so that f ''(r) = 0.
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, ava1018
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
Answers: 1
You know the right answer?
Ineed writing a prgram for a crab the current code is posted below the question.1. double-click on...

Questions in other subjects:

Konu
Mathematics, 03.02.2021 01:00
Konu
Mathematics, 03.02.2021 01:00
Konu
Mathematics, 03.02.2021 01:00
Konu
Mathematics, 03.02.2021 01:00