User Tools

Site Tools


newspaper_retrieval

Differences

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

Link to this comparison view

Next revision
Previous revision
newspaper_retrieval [2019/08/17 23:27] – created frchrisnewspaper_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>KarelWorld <code java>KarelWorld
Line 21: Line 21:
 northsouthwalls 3 4 4 northsouthwalls 3 4 4
 northsouthwalls 3 6 6</code> northsouthwalls 3 6 6</code>
 +
 +
 +You can download this kwld file: [[https://mathorama.com/karel/CollectNewspaper.kwld|CollectNewspaper.kwld]]
 +
 +{{::karelnewspaper.png?400|}}
 +
 +
 +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.readWorld("CollectNewspaper.kwld");
 +    World.getWorld("KarelWorld\n"
 +    "streets 10\n" + 
 +    "avenues 10\n" + 
 +    "beepers 3 3 1\n" + 
 +    "eastwestwalls 5 3 3\n" + 
 +    "eastwestwalls 6 6 6\n" + 
 +    "eastwestwalls 6 5 5\n" + 
 +    "eastwestwalls 2 6 6\n" + 
 +    "eastwestwalls 6 4 4\n" + 
 +    "eastwestwalls 2 5 5\n" + 
 +    "eastwestwalls 2 4 4\n" + 
 +    "eastwestwalls 4 3 3\n" + 
 +    "northsouthwalls 6 3 3\n" + 
 +    "northsouthwalls 6 4 4\n" + 
 +    "northsouthwalls 6 5 5\n" + 
 +    "northsouthwalls 6 6 6\n" + 
 +    "northsouthwalls 3 3 3\n" + 
 +    "northsouthwalls 3 4 4\n" + 
 +    "northsouthwalls 3 6 6");
 +    World.setVisible();
 +    task();
 +    }
 +    public static void task()
 +    {
 +    Robot karel = new Robot(3,4,West,0);
 +   
 +    }
 +}
 +
 +</code>
 +
 +[[http://csis.pace.edu/%7Ebergin/KarelJava2ed/KJRdocs/index.html|Karel J Robot API]] (Application Programming Interface)
 +
newspaper_retrieval.1566098875.txt.gz · Last modified: 2019/08/17 23:27 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki