Source of SpeciesTest.java


  1: public class SpeciesTest
  2: {
  3:         public static void main(String[] args)
  4:         {
  5:                 Species testSpecies = new Species();
  6: 
  7:                 // Test the setSpecies method
  8:                 testSpecies.setSpecies("Tribbles", 100, 50);
  9:                 if (testSpecies.getName().equals("Tribbles") &&
 10:                     (testSpecies.getPopulation() == 100) &&
 11:                     (testSpecies.getGrowthRate() >= 49.99) &&
 12:                     (testSpecies.getGrowthRate() <= 50.01))
 13:                 {
 14:                         System.out.println("Pass: setSpecies test.");
 15:                 }
 16:                 else
 17:                 {
 18:                         System.out.println("FAIL: setSpecies test.");
 19:                 }
 20: 
 21: 
 22:                 // Test the predictPopulation method
 23:                 if ((testSpecies.predictPopulation(-1) == 100) &&
 24:                     (testSpecies.predictPopulation(1) == 150) &&
 25:                     (testSpecies.predictPopulation(5) == 759))
 26: 
 27:                 {
 28:                         System.out.println("Pass: predictPopulation test.");
 29:                 }
 30:                 else
 31:                 {
 32:                         System.out.println("FAIL: predictPopulation test.");
 33:                 }
 34:         }
 35: }