Question: Use Selection, Sequence and iteration when necessary to do the following tasks: 1. Create a static method called turnRight() and another static method called uTurn().

Use Selection, Sequence and iteration when necessary to do the following tasks:

1. Create a static method called turnRight() and another static method called uTurn().

2. Create the logic and write the Java code that would have the robot:

A) Move through the tunnel and pick up the Things on its way, stopping when it reaches the end of the tunnel (ie. Avenue 6, Street 6).

B) Turn around, and move back as many times as it moved forward in part (A), and drop off all the Things at avenue 2, street 4 (Starting location).

Note:

1. Use concept of Inheritance in order to override and use move(), turnLeft(), canPickThing() and PickThing() methods in your solution.

2. Your code should work if the tunnel had more or less things in it and if the tunnel was longer or shorter as well (The shape of this tunnel will remain the same).

3. Therefore, DO NOT hardcode this program, but you can assume that the robot turns right when it is at intersection (Street 4, Avenue 6).

4. Be consistent! Choose to create either static or instance methods and stick to it.

5. Do not write code for initialization of City, Robot, walls and things. Assume the environment is pre-setup as in diagram. Hence, write Java code of only your logic as solution to solve the above mentioned problem.

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!