// Fall 2010 import tester.*; /* +----------------------------+ | +------------------------+ | | | | | v v | | +-------+ | | | IMaze | | | +-------+ | | / \ | | --- | | | | | -------------------- | | | | | | +--------------+ +-------------+ | | | Treasure | | Room | | | +--------------+ +-------------+ | | | String booty | | IMaze left |-+ | +--------------+ | IMaze right |---+ +-------------+ */ // to represent a maze interface IMaze{ } // to represent the booty found in a maze class Treasure implements IMaze{ String booty; Treasure(String booty){ this.booty = booty; } } // to represent a room in a maze class Room implements IMaze{ IMaze left; IMaze right; Room(IMaze left, IMaze right){ this.left = left; this.right = right; } } // to represent examples of IMaze class hierarchy class ExamplesMaze{ ExamplesMaze(){} IMaze gold = new Treasure("gold"); IMaze silver = new Treasure("silver"); IMaze diamond = new Treasure("diamond"); IMaze muck = new Treasure("muck"); IMaze mud = new Treasure("mud"); IMaze small = new Room(this.muck, this.silver); IMaze maze = new Room( new Room( new Room(this.muck, this.silver), this.gold), new Room( this.diamond, this.mud)); //test the method contains for the IMaze class hierarchy boolean testContains(Tester t){ return t.checkExpect(this.gold.contains("gold"), true); } }