Spring Semester 2005


Lab One: Programs (in Java). Creation, compilation, execution.
We've written some programs for you to play with.

Create a folder on your desktop and copy the following files in it:

Now add two more files to the folder:

Finally copy this last program in your folder, and you're ready to start:

Once you have all these files in the folder you're ready to proceed.

  1. The first thing we want you to do is to compile SliderTest and run it.

  2. Then we want you to compile One.java and run it.

  3. Then compile Dance.java and run it.

If things run smoothly your last two programs will look something like this:

So here's your lab assignment for next time.

A201/A597 LAB ASSIGNMENT ONE

Write two programs.

A. First write a program as described below.

In your program:

  1. Create a square room composed of 100 tiles (10 x 10, that is).
  2. Create a Penguin, and add it to the room in the 8th line and 3rd column.
  3. That means tile (7, 2) given our the numbering convention.
  4. So, please take some time to review the numbering convention now.
  5. Now ask the penguin to turn around and move to tile (2, 2).
  6. Then ask the penguin to turn right, then move to tile (2, 7).
  7. Then make the penguin turn right, and have it move to tile (7, 7).
  8. Now ask the penguin to move to tile (2, 7).
  9. And finally have it return to (7, 2), passing through (2, 2).

In writing this program the following summary should help:

A Penguin:

A Rink:

Note though that when the Rink shows, it labels the cells by first printing the line, then the column, for each of the tile. The reason this numbering is also important is because it is the numbering used in 2 dimensional arrays in Java (of the kind we will encounter a bit later).

Note that x and y still keep the meaning that they originally had:

When we create the Rink, and when we add a Penguin to it, we mention x first, and y next, almost as we do in analytical geometry. However when we refer to the table of cells that the Rink is, we can also denote the cells in the array by printing (y, x), that is, by specifying the line first, and the column next. The point being that both notations are well-established, and we need to be aware of them both.

You should now write the program with no problems.

And here's a picture of Wallace and Gromit from The Wrong Trousers to remind you of it, and for motivation.

Greetings...

The Aardman Penguin is pictured in disguise at the beginning of the assignment.

B. The second part of the assignment asks you to write a program that prints the following strange picture exactly as shown:

         /--\
         |\n|
      /--+--+
      '  "  "
   /--+--+--+
   '  "  "  "
/--+--+--+--+
|\n|\n|\n|\n|
\--+--+--+--/

You need to show these programs to the AI next week, in lab.

You also need to be able to take questions on the programs.

You also need to be able to take questions on the topics covered in class during the first week.

Please practice the programs and concepts shown in class Tue and Thu.

They have been posted as Lecture Notes One and Two.


Last updated by Adrian German for A201/A597/I210 on Thu Jan 13 08:16:57 EST 2005