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