All pastes #166414 Raw Edit

Something

public text v1 · immutable
·published 2006-09-10 21:57 UTC
rendered paste body
Lab02
Escape the Maze Objective Inheritance.  
Defining instance methods. Background Escaping the maze shown below involves both left turns and right turns.  Since our robots only know how to turn left we will define another type of object (athlete) in a separate class (Athlete) that knows how to turn both left and right, and 180 degrees around.  The structure of Athlete.java is shown.
The keyword extends means that an athlete isa robot.  Isa means that the Athlete class inherits the behaviors and attributes of the Robot class; the methods from Robot do not have to be re-written.  We can use turnLeft in our definition of turnRight and turnAround, and any athlete object can use any robot method.
Athlete is not a program even though it is a class.  No specific object is mentioned by name because you are creating a general resource that will be useful to a wide range of applications.  Java uses the same keyword class to stand for both resources and applications.
Specification
Load Unit1\Athlete.java.  Implement the methods turnRight and turnAround, then compile Athlete.java to create the file Athlete.class.  When you create an athlete object in your Lab02 application, Java will look for the Athlete.class file in order to understand what athlete objects do.  Do not run Athlete.
Create Unit1\Lab02.java with “maze” world at size 8x8.  Use one athlete object to escape the maze.  Leave a trail of beepers to mark the path.  By default, athletes begin with an infinite number of beepers.