your_initials_in_beepers
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| your_initials_in_beepers [2019/08/17 12:01] – created frchris | your_initials_in_beepers [2019/08/18 12:40] (current) – frchris | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Your Initials in Beepers ====== | ====== Your Initials in Beepers ====== | ||
| - | Draw your | + | Have a robot with a name of you choosing draw spell out your initials using beepers. Make the initials at least 5 beepers high. Here is an example if your initials happen to be '' |
| + | |||
| + | {{http:// | ||
| + | |||
| + | Here is some starter code for a new class. | ||
| + | |||
| + | |||
| + | [[http:// | ||
| + | |||
| + | <code java> | ||
| + | import kareltherobot.*; | ||
| + | /** | ||
| + | * | ||
| + | * @author Your Name Here | ||
| + | * @version Aug 19, 2019 | ||
| + | | ||
| + | | ||
| + | */ | ||
| + | public class DrawInitials implements Directions | ||
| + | { | ||
| + | public static void main(String[] args) | ||
| + | { | ||
| + | World.setDelay(30); | ||
| + | World.setSize(8, | ||
| + | World.setVisible(); | ||
| + | task(); | ||
| + | } | ||
| + | |||
| + | public static void task() | ||
| + | { | ||
| + | |||
| + | Robot lisa = new Robot(5, 1, South, infinity); | ||
| + | |||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.turnLeft(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.putBeeper(); | ||
| + | lisa.move(); | ||
| + | lisa.turnOff(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ====== Making a method ====== | ||
| + | With all those '' | ||
| + | * Places n beepers from Robot r ina striaght line | ||
| + | * @param r the Robot placing the beepers | ||
| + | * (precondtion: | ||
| + | * @param n the number of beepers to place | ||
| + | */ | ||
| + | public static void placeSomeBeepers(Robot r, int n) | ||
| + | { | ||
| + | for (int i=0; i < n; i++) | ||
| + | { | ||
| + | r.putBeeper(); | ||
| + | r.move(); | ||
| + | } | ||
| + | }</ | ||
| + | |||
| + | Now all your '' | ||
| + | { | ||
| + | |||
| + | Robot lisa = new Robot(5, 1, South, infinity); | ||
| + | |||
| + | placeSomeBeepers(lisa, | ||
| + | lisa.turnLeft(); | ||
| + | placeSomeBeepers(lisa, | ||
| + | lisa.move(); | ||
| + | lisa.turnOff(); | ||
| + | }</ | ||
your_initials_in_beepers.1566057692.txt.gz · Last modified: 2019/08/17 12:01 by frchris