|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs4099.Interpreter
public class Interpreter
This class interprets an XML file for use in the main program. If the XML file does
not conform to the expected format, an error message will be displayed.
The purpose of the code is to construct a root state from which a game is to be played.
State
Constructor Summary | |
---|---|
Interpreter()
|
Method Summary | |
---|---|
boolean |
booleanRead(org.w3c.dom.NamedNodeMap piledata,
java.lang.String property,
boolean defaultvalue)
Method to read a boolean property from the XML and to return it if it exists. |
boolean |
getBool(java.lang.String string)
This method converts a String into a boolean, returning true if the contents of the String are equal to "true", and false if the contents are anything else. |
int |
intRead(org.w3c.dom.NamedNodeMap piledata,
java.lang.String property,
int defaultvalue)
Method to read an int property from the XML and to return it if it exists. |
java.util.LinkedList |
makedecks(int deckstogenerate)
Sets up the initial set of cards to use - a number of packs specified by the file. |
State |
setupGame(java.lang.String filename)
A large method to go through the entire process of reading the properties of the XML file (game, piles, fixed cards and tactics) and storing them in a State ready for use by the program. |
java.util.LinkedList |
shufflepack(java.util.LinkedList pack,
int shuffledepth)
Shuffles a given array of cards, by repeatedly swapping two positions chosen at random. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Interpreter()
Method Detail |
---|
public State setupGame(java.lang.String filename)
filename
- The file to interpret.
public java.util.LinkedList makedecks(int deckstogenerate)
public java.util.LinkedList shufflepack(java.util.LinkedList pack, int shuffledepth)
pack
- The array of cards to be shuffled.shuffledepth
- The number of swaps to perform.
public boolean booleanRead(org.w3c.dom.NamedNodeMap piledata, java.lang.String property, boolean defaultvalue)
piledata
- The node map from which to get data.property
- The name of the property to search for.defaultvalue
- The default value if the property is not found.
public boolean getBool(java.lang.String string)
string
- The string to examine.
public int intRead(org.w3c.dom.NamedNodeMap piledata, java.lang.String property, int defaultvalue)
piledata
- The node map from which to get data.property
- The name of the property to search for.defaultvalue
- The default value if the property is not found.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |