User Tools

Site Tools


a_task_for_two_robots

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
a_task_for_two_robots [2019/08/18 10:33] – created frchrisa_task_for_two_robots [2019/08/18 10:41] frchris
Line 1: Line 1:
 ====== A Task For Two Robots ====== ====== A Task For Two Robots ======
 +Karel is at 3rd street and 1st avenue on a corner facing East. There is a beeper at 2nd street and 1st avenue. Jane is at the origin facing East.  Karel should pick up the beeper and bring it to Jane.  Jane should then pick it up and carry it to 1st street and 4th avenue.  The beeper should be placed on this corner.
 +
 +<code java>
 +/** 
 + * First.java
 + *
 + * Title: Chapter 2.9 p. 19
 + * Description: Move a beeper from position 1,4 to position 3,5
 + * @author Golden Knight
 + * @version August 19, 2019
 + */
 +import java.awt.Color;
 +
 +import kareltherobot.*;
 +public class TaskForTwoRobots implements Directions 
 +{
 + public static void task() 
 +        {
 + Robot karel = new Robot(3, 1, East, 0 , Color.RED);
 + Robot jane = new Robot(1, 1, East, 0, Color.BLUE);
 + karel.turnLeft();
 + karel.turnLeft();
 + karel.turnLeft();
 +
 + karel.move();
 + karel.pickBeeper();
 + karel.move();
 +
 + karel.turnLeft();
 + karel.putBeeper();
 + jane.pickBeeper();
 + jane.move();
 + jane.move();
 + jane.move();
 + jane.putBeeper();
 + jane.move();
 +
 + karel.turnOff();
 + jane.turnOff();
 + }
 + // Main method is where the application starts execution
 + public static void main(String[] args) 
 +        {
 + World.setDelay(50); 
 + World.placeBeepers(2, 1, 1);
 + World.setVisible();
 +
 + task();
 + }
 +}
 +
 +
 +</code>
a_task_for_two_robots.txt · Last modified: 2019/08/18 12:36 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki