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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
What is outfitting a workplace with video in a technology
Answers: 2
question
Computers and Technology, 22.06.2019 22:20
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
As with any small island country, cuba has fewer natural resources than countries such as brazil. this affects their economy in that cuba a) exports only manufactured products. b) exports more products than it imports.. c) must import more products than it exports. d) has imposed trade barriers against the united states.
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
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
Questions on the website: 13722361