User Tools

Site Tools


newspaper_retrieval

This is an old revision of the document!


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. 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:

KarelWorld
streets 10
avenues 10
beepers 3 3 1
eastwestwalls 5 3 3
eastwestwalls 6 6 6
eastwestwalls 6 5 5
eastwestwalls 2 6 6
eastwestwalls 6 4 4
eastwestwalls 2 5 5
eastwestwalls 2 4 4
eastwestwalls 4 3 3
northsouthwalls 6 3 3
northsouthwalls 6 4 4
northsouthwalls 6 5 5
northsouthwalls 6 6 6
northsouthwalls 3 3 3
northsouthwalls 3 4 4
northsouthwalls 3 6 6

Here is some starter code:

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("filename");
    	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);
 
    }
}
newspaper_retrieval.1566099793.txt.gz · Last modified: 2019/08/17 23:43 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki