Lab 3: More on Oolong


Remember, if you haven't already done this permanently, you'll need to set your path correctly:


Iteration

To get a little practice with iteration (labels and jumps in oolong), try implementing methods that implement the following functions:
  1. Triangular numbers:
  2. The Fibonacci sequence:
  3. Square root of some number N by guessing:
Here is a sample solution.


Robots

Here's the source code for a simple robot that I was using with the first years. Your task is to write a controller for the robot - the program should run by taking a list of instructions in using the command line arguments.

Each robot knows its location - in (across,down) co-ordinates - and its orientation - north, south, east or west. You can issue commands to the robot to move it around. The valid commands are:

L Turn 90 degrees to the left
R Turn 90 degrees to the right
num Move forward by num steps (in the current direction)
DCalculate the distance from the origin, rounded down to a whole number

For example, here is a sequence of commands to move the robot five steps forward, four to the left, and six steps backwards again: (The robot is initially facing north)

Your program should create a Robot object and then go through the comand line arguments, calling the appropriate method to perform each action.


NUIM Logo James Power,
Dept. of Computer Science
Last revised: 6 March 2000