|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Item
This interface specifies how all Item classes in the game must be built. All items must have the methods declared here defined within their classes or the game will not compile. Inheriting from this class does not limit items to these methods however; more can easily be added.
To create another item, create a new class that implements the Item interface. Make sure your class has all these methods.
| Method Summary | |
|---|---|
void |
draw(GameState game,
java.awt.Graphics g,
int windowWidth,
int windowHeight,
int itemIndex)
Draws the item to the screen at position windowWidth - 100 * itemIndex, windowHeight - 100. |
java.lang.String |
getName()
Returns the name of this item object as a String. |
void |
outputDescription(GameState game,
OutputPanel output)
Prints text describing this item to the output panel. |
boolean |
takeAction(GameState game,
OutputPanel output,
java.lang.String verb,
java.lang.String noun)
This method is called when the user enters a command. |
| Method Detail |
|---|
java.lang.String getName()
Students may often call this method.
void outputDescription(GameState game,
OutputPanel output)
It would be uncommon for students to call this method.
game - the GameState object that is running / keeping track of this gameoutput - the output panel where text will be added
boolean takeAction(GameState game,
OutputPanel output,
java.lang.String verb,
java.lang.String noun)
This method should return false if the command was not processed here. It should return true if the command was processed here.
It would be uncommon for students to call this method.
game - the GameState object that is running / keeping track of this gameoutput - the output panel where text will be addedverb - the verb of the action, such as "get"noun - the noun of the action, such as "batteries"
void draw(GameState game,
java.awt.Graphics g,
int windowWidth,
int windowHeight,
int itemIndex)
It would be uncommon for students to call this method.
game - the GameState object that is running / keeping track of this gameg - the Graphics object to do the drawingwindowWidth - the width of the windowwindowHeight - the height of the windowitemIndex - the relative position of this item (0 = first, rightmost)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||