Chest - if(this.lock == theKey){ this.isLocked = false; } }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Chest { p /* * Instance variables go here, you're responsible for choosing * which ones are needed and naming them */ private boolean isLocked = false; private String contents; private Key lock; p /** * This method is used by the Map class, you won't need to call it yourself * It should result in this chest being locked and storing which key locked it. */ public void lock(Key theKey) { this.lock = theKey; this.isLocked = true; } /** * If theKey is the same key that was used to lock this chest, then * the chest is unlocked. Otherwise this method does nothing. */ public void unLock(Key theKey) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(this.lock == theKey){ this.isLocked = false; } } /** * Should return true if the chest is locked, false otherwise */ public boolean isLocked() { return this.isLocked; } /** * Return a string describing the contents of the chest. */ public String getContents() { return this.contents; } /** * Set the contents of the chest to this string. You should not need to call * this method in your program (though you have to implement it anyway). */ public void setContents(String contents) { this.contents = contents; } }...
View Full Document

This note was uploaded on 11/15/2010 for the course CSCI 01209 taught by Professor Storm during the Fall '10 term at University of Georgia Athens.

Ask a homework question - tutors are online