milewalker
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| milewalker [2019/08/23 09:28] – created frchris | milewalker [2019/08/23 09:37] (current) – [MileWalkerRunner] frchris | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| <code java> | <code java> | ||
| - | public class MileWalker extends Robot // note the capital letters for the class name | + | import kareltherobot.*; |
| + | |||
| + | public class MileWalker extends Robot | ||
| + | // note the capital letters for the class name | ||
| { | { | ||
| - | public void moveMile() | + | public MileWalker(int street, int avenue, |
| + | Direction direction, int beepers) | ||
| + | { | ||
| + | super(street, | ||
| + | } | ||
| + | |||
| + | | ||
| { | { | ||
| - | move(); move(); move(); move(); | + | move(); move(); move(); move(); |
| move(); move(); move(); move(); | move(); move(); move(); move(); | ||
| } | } | ||
| Line 15: | Line 24: | ||
| ====== MileWalkerRunner ====== | ====== MileWalkerRunner ====== | ||
| <code java> | <code java> | ||
| - | task() | + | import kareltherobot.*; |
| - | { | + | |
| - | | + | /** |
| - | | + | * |
| - | | + | * @author Chris Thiel |
| - | | + | * @version Aug 19, 2019 |
| - | lisa.move(); | + | |
| - | lisa.pickBeeper(); | + | |
| - | lisa.moveMile(); | + | |
| - | lisa.turnOff(); | + | */ |
| + | |||
| + | public class MileWalkerRunner implements Directions { | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | World.setDelay(50); | ||
| + | World.setVisible(); | ||
| + | task(); | ||
| + | } | ||
| + | public static void task(){ | ||
| + | // Declare a instance of a MileWalker Robot: | ||
| + | MileWalker lisa = new MileWalker (3, 2, East, 0); | ||
| + | |||
| + | lisa.moveMile(); | ||
| + | lisa.pickBeeper(); | ||
| + | lisa.turnLeft(); | ||
| + | lisa.move(); | ||
| + | lisa.pickBeeper(); | ||
| + | lisa.moveMile(); | ||
| + | lisa.turnOff(); | ||
| + | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
milewalker.1566566906.txt.gz · Last modified: 2019/08/23 09:28 by frchris