a_task_for_two_robots
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
a_task_for_two_robots [2019/08/18 10:33] – created frchris | a_task_for_two_robots [2019/08/18 12:36] (current) – 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. | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * First.java | ||
+ | * | ||
+ | * Title: Chapter 2.9 p. 19 | ||
+ | * Description: | ||
+ | * @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, | ||
+ | World.setVisible(); | ||
+ | |||
+ | task(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </ |
a_task_for_two_robots.txt · Last modified: 2019/08/18 12:36 by frchris