|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSpecies
public class Species
The individual creatures in the world are all representatives of some species class and share certain common characteristics, such as the species name and the program they execute. Rather than copy this information into each creature, this data can be recorded once as part of the description for a species and then each creature can simply include the appropriate species pointer as part of its internal data structure.
To encapsulate all of the operations operating on a species within this abstraction, this provides a constructor that will read a file containing the name of the creature and its program, as described in the earlier part of this assignment. To make the folder structure more manageable, the species files for each creature are stored in a subfolder named Creatures. This, creating the Species for the file Hop.txt will causes the program to read in "Creatures/Hop.txt".
Note: The instruction addresses start at one, not zero.
Constructor Summary | |
---|---|
Species(String fileName)
Create a species for the given file. |
Method Summary | |
---|---|
String |
getColor()
Return the color of the species. |
String |
getName()
Return the name of the species. |
static void |
main(String[] s)
|
int |
programSize()
Return the number of instructions in the program. |
Instruction |
programStep(int i)
Return an instruction from the program. |
String |
programToString()
Return a String representation of the program. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Species(String fileName)
Method Detail |
---|
public String getName()
public String getColor()
public int programSize()
public Instruction programStep(int i)
public String toString()
toString
in class Object
public String programToString()
public static void main(String[] s)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |