Lab 1: CodeWarrier,  How to Hand in Programs, Karel's World 



Homework 1 Due Date: Wed August 29 by 11:59PM


Background:

Homework 1 will introduce you to the Code-Warrier Software package that you will use to write your Karel and Java programs for 15-100. We will practice the edit / compile / run cycle of program development. Once you have sucessfully edited, compiled and executed this simple Karel program you will use the Intro-CS Assignment Dropoff form to hand in your finished program

You will then solve two more Karel problems.


Warmup Exercise to prepare for the Assignment

Download the hw1.zip file by clicking on this link. Save the zip file to your C:\Temp directory and unzip the files. You will see two directories for hw1a and hw1b. Inside hw1a you should see the following files:
  • KarelProject.mcp (the project file for this Karel Program)
  • Main.java (the source file for this Karel program)
  • KarelLib.jar (a library of Karel commands)
  • first.txt (a description of the task world for this problem)
  • four .gif image files kareln.gif, karele.gif, karels.gif, karelw.gif
Open the KarelProject.mcp file and look at the filenames listed inside. KarelProject.mcp is not a Karel or Java program file - it s project file CodeWarrier requires as part of every Java program. A project file keeps track of what files are part of a Java program. Typically there is one project file for each Java program -- however there can be many Java source files comprising a single Java program. The program we are going to work with today only has 1 source file:    Main.java.

At the top of the file, you see a section of code that is enclosed by the /** */ combination. This informs the compiler that the information enclosed is not code, and can be safely ignored. In this particular section you should type you name, section, and assignment (in this case, Lab 1)

The next section has a statement package kareltherobot; A package contains the files/definitions of closely related classes. A class defined in a particular package can make use of other classes defined in the package. All of our Karel programs will become part of the kereltherobot package.

Notice the three lines that begin with the // special symbol. This is another instruction for the compiler, telling it to ignore everything that follows until the end of the line.

Let's compile and execute this program and see what output it produces. Go to the top of the project window and select Project / Run or click the small arrow head (looks like the Play button on a VCR / DVD player) in the middle of the project window menu bar.

Karel is displayed in the work of this problem. He is facing a wall, with a beeper on the opposite side of the wall.

Make a small change to the program
Let's make a change to our program. After the line:

   // insert Karel instructions here

type the following two lines: 

    Karel.turnLeft();
    Karel.move();

pay attention to capitalization and punctuation. 

Run the project again. Notice that Karel has moved from its starting position. 

Finish the task
Write the instructions so that Karel will pick up the beeper, carry it to origin, put it down, and then move to the corner one block north of origin.

Use the robot primitive instructions we discussed in lecture

  • move()
  • turnleft() 
  • pickBeeper()
  • putBeeper()


Homework 1b: Due at the end of the class
 

Open the directory for hw1b.

Compile and execute this program and you will see that Karel is in his bed inside of his house. Outside there is a newpaper, symbolized by a beeper. 

Write the instructions that will have Karel go, pick up the newspaper, and return to his bed to read it. He must be facing the same direction at the end of the program as when it starts, because Karel's head must be on the pillow in his bed as he reads his paper. 


Handing in your Solution

Your solutions should be in the form of .zip files. When we grade your solution we will unzip the folder and execute the project. If your project does not run you will lose the execution points for that lab.

Your Solution zip file must contain all the files in your projects

You will be shown how to zip up the files for submission. Instructions are also in the Tutorial document that is available
 

Click on this link to Submit your zip file