/** EcoSystem will model the interactions between species in
 *  an ecosystem.
 */
import java.io.*;
public class EcoSystem{
  // this BufferedReader is static so there is a single copy for
  // the entire EcoSystem class, not one per instance.  Similarly,
  // we'll want a PrintStream to print to files.
  private static BufferedReader br;
  private static PrintStream ps;

  // main method is what Java "runs"
  // it needs a 'throws IOException' clause because it uses
  // a BufferedReader
  public static void main(String[] args) throws IOException {
    // input.txt had better exist, and output.txt will
    // be clobbered
    br= new BufferedReader(new FileReader("input.txt"));
    ps= new PrintStream(new FileOutputStream("output.txt"));

    // create a string by reading population and name
    // from input.txt
    String inputString;
    int inputInt;
    inputString= br.readLine();
    inputInt= Integer.parseInt(br.readLine());

    // create a Species specified in the first two lines of
    // input.txt
    Species gorilla= new Species(inputInt, inputString);

    // Write something meaningful about gorilla
    ps.println("Species " + gorilla.getName() +
		       " has " + gorilla.getPopulation() +
		       " members.");

    // create a Species
    Species gnu= new Species(7,"gnu gnusance");

    // print its population
    System.out.println("gnu population: "+ gnu.getPopulation());

    //add another species, plus species names
    Species gnat;
    gnat= new Species(1000,"gnat gnattus");


    // add a species equivalent to gnu
    Species ung= new Species(7,"gnu gnusance");
    System.out.println("gnu same as ung: " + gnu.equals(ung));
    ung.setTerritory("South-Central Ontario");
    System.out.println("gnu same as ung: " + gnu.equals(ung));
    gnu.setTerritory("South-Central Ontario");
    System.out.println("gnu same as ung: " + gnu.equals(ung));

    // How many species are there now?
    System.out.println("There are now " + Species.getCount() +
		       " species in this EcoSystem.");
  }
}

