Source of SpeciesSecondTryDemo.java


  1: //SpeciesSecondTryDemo.java
  2: 
  3: /**
  4:  * Demonstrates the use of a parameter
  5:  * with the method projectedPopulation.
  6:  */
  7: public class SpeciesSecondTryDemo
  8: {
  9:     public static void main(String[] args)
 10:     {
 11:         SpeciesSecondTry speciesOfTheMonth = new SpeciesSecondTry();
 12: 
 13:         System.out.println("Enter data on the Species of the Month:");
 14:         speciesOfTheMonth.readInput();
 15:         speciesOfTheMonth.writeOutput();
 16:         int futurePopulation = speciesOfTheMonth.predictPopulation(10);
 17:         System.out.println("In ten years the population will be "
 18:             + futurePopulation);
 19: 
 20:         //Change the species to show how to change 
 21:         //the values of instance variables:
 22:         speciesOfTheMonth.name = "Klingon ox";
 23:         speciesOfTheMonth.population = 10;
 24:         speciesOfTheMonth.growthRate = 15;
 25:         System.out.println("The new Species of the Month:");
 26:         speciesOfTheMonth.writeOutput();
 27:         System.out.println("In ten years the population will be "
 28:             + speciesOfTheMonth.predictPopulation(10));
 29:     }
 30: }