Class Species

java.lang.Object
  extended by Species

public class Species
extends Object

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

Species

public Species(String fileName)
Create a species for the given file.

Method Detail

getName

public String getName()
Return the name of the species.


getColor

public String getColor()
Return the color of the species.


programSize

public int programSize()
Return the number of instructions in the program.


programStep

public Instruction programStep(int i)
Return an instruction from the program.


toString

public String toString()
Overrides:
toString in class Object

programToString

public String programToString()
Return a String representation of the program.


main

public static void main(String[] s)