ITEC 120
L09b: Explorer

Objectives

To successfully complete this lab you will develop classes that represent an explorer. You will declare and access private instance variables and you will develop a con­structor, getter and setter methods, and toString method.

Assignment

Develop the Explorer class:

Create a class named Explorer with four properties that are only accessible from within the class.

Notice that 3 pieces of an Explorer's instance data are pointers to objects. You will need the Treasure.java and Room.java that you wrote for the previous two labs in addition to Explorer.java which you will write for this lab. Put all those files in the L09a directory you've created for this lab.

Constructors, Getters, Setters, and toString()

Create a constructor for Explorer. Have the caller pass a value for all of the object's properties. Create getter and setter methods for all instance variables. Create a toString() method for each class that returns a string containing the name of each property and the current value.  For example:

Explorer: Dora
Left Pocket: Lint
Right Pocket: Golden key
Room: Start room

ExplorerTest

Create a class named ExplorerTest. In the driver, create a treasure named lint, a piece of dust, with zero weight and zero value.  Create a second treasure, a key, a golden key, with weight 5 and value 25.  Create a Start Room, a cold, dark, damp place that contains the golden key.  Create an explorer.  Give your explorer a name, put the explorer in the Start Room, and put lint in each pocket.  Print your explorer and the room your explorer is in and the treasure that is in the room, for example: 

Explorer: Dora
Left Pocket: Lint
Right Pocket: Lint
Room: Start room     

Room: Start room      
Description: a cold, dark, damp place
Treasure: Key

Name: Key
Description: Golden Key
Weight: 1.5  Value: 25


Submit Your Assignment

Submit 4 files:
ExplorerTest.java, Explorer.java, Room.java, and Treasure.java
to the L09b dropbox on D2L.