newspaper_retrieval
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
newspaper_retrieval [2019/08/17 23:27] – created frchris | newspaper_retrieval [2022/08/23 09:40] (current) – frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Newspaper Retrieval ====== | ====== Newspaper Retrieval ====== | ||
- | Every morning Karel is awakened in bed when the newspaper, represented by a beeper, is thrown on the front porch of his house. Program Karel to retrieve the paper and bring it back to bed. | + | Every morning Karel is awakened in bed when the newspaper, represented by a beeper, is thrown on the front porch of his house. Program Karel to retrieve the paper and bring it back to bed. Karel is inside in the southwest corner (Street 3, Avenue 4), while the newspaper is outside on the other side of the wall (Street 3, Avenue 3) Below is the description of the world: |
<code java> | <code java> | ||
Line 21: | Line 21: | ||
northsouthwalls 3 4 4 | northsouthwalls 3 4 4 | ||
northsouthwalls 3 6 6</ | northsouthwalls 3 6 6</ | ||
+ | |||
+ | |||
+ | You can download this kwld file: [[https:// | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | |||
+ | Here is some starter code: | ||
+ | <code java> | ||
+ | import java.awt.Color; | ||
+ | import kareltherobot.*; | ||
+ | public class Newspaper implements Directions | ||
+ | { | ||
+ | public static void main(String[] args) | ||
+ | { | ||
+ | World.setDelay(30); | ||
+ | World.setBeeperColor(Color.BLUE); | ||
+ | // | ||
+ | World.getWorld(" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | World.setVisible(); | ||
+ | task(); | ||
+ | } | ||
+ | public static void task() | ||
+ | { | ||
+ | Robot karel = new Robot(3, | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | [[http:// | ||
+ |
newspaper_retrieval.1566098875.txt.gz · Last modified: 2019/08/17 23:27 by frchris