Source of SpeciesFourthTryDemo.java


  1: //SpeciesFourthTryDemo.java
  2: 
  3: import java.util.Scanner;
  4: 
  5: /**
  6:  * Demonstrates the use of the mutator method setSpecies.
  7:  */
  8: public class SpeciesFourthTryDemo
  9: {
 10:     public static void main(String[] args)
 11:     {
 12:         SpeciesFourthTry speciesOfTheMonth = new SpeciesFourthTry();
 13: 
 14:         System.out.println("Enter number of years to project:");
 15:         Scanner keyboard = new Scanner(System.in);
 16:         int numberOfYears = keyboard.nextInt();
 17: 
 18:         System.out.println("Enter data on the Species of the Month:");
 19:         speciesOfTheMonth.readInput();
 20:         speciesOfTheMonth.writeOutput();
 21:         int futurePopulation =
 22:              speciesOfTheMonth.predictPopulation(numberOfYears);
 23:         System.out.println("In " + numberOfYears
 24:             + " years the population will be " + futurePopulation);
 25: 
 26:         //Change the species to show how to change 
 27:         //the values of instance variables:
 28:         speciesOfTheMonth.setSpecies("Klingon ox", 10, 15);
 29:         System.out.println("The new Species of the Month:");
 30:         speciesOfTheMonth.writeOutput();
 31: 
 32:         futurePopulation = speciesOfTheMonth.predictPopulation(numberOfYears);
 33:         System.out.println("In " + numberOfYears
 34:             + " years the population will be " + futurePopulation);
 35:     }
 36: }