Fetch the Newspaper

6 points

Introduction
Help Karel the Robot to get out of bed, fetch the newspaper that is sitting on the sidewalk in front of his house, and go back to bed to read the newspaper. Before you can do any programming to enable Karel to do this, you'll first need to create a world that includes Karel's house and the newspaper.

Creating a World
What is a world? Well, here is a screenshot of a world file I created that includes Karel's house and the newspaper on the front sidewalk. The image also shows Karel asleep in his bed, although the robot is not really a part of the 'world'.

To create a world, look for the program 'KarelJRobot'. Running this program brings up the World Builder. To create a vertical wall segment, click on 'Vertical Wall' and click in the world where you want to wall to be. To create a horizontal wall segment, click on 'Horizontal Wall'. To add a beeper, click on 'Beeper'.

To delete a wall segment, CTRL-Click on the wall. To delete a beeper, CTRL-Click on the beeper.

More information is available on creating worlds on the creator's web page at csis.pace.edu/~bergin/KarelJava2ed/karelexperimental.html. Scroll down to the section "How to Build a World".

Once you've got Karel's house built, and the newspaper on the front sidewalk, save the world (yes, in this class you get to SAVE THE WORLD!) in a file, possibly 'paper.kwld'. The 'kwld' extension is optional. You want 'paper.kwld' to be located inside the 'classes' folder in your Karel project.

Fetching the Newspaper
You'll want to use these methods in getting Karel to walk to his newspaper, pick up the paper and return to bed:

Download the file listed below under 'Starting Point' and add your commands to that file.

 

Starting Point

You can download GetThePaper.java to use as a starting point in writing your program.