コード例 #1
0
 /** Tests the eat method in the organism class */
 @Test
 public void testEat() {
   Cell middle = new Cell(2, 2);
   Cell west = new Cell(1, 2);
   system.add(rabbit, middle);
   system.add(insect, west);
   rabbit.eat(middle, system);
   String now = "xxxxxMxxx";
   assertEquals(now, printX());
 }
コード例 #2
0
 /** Tests the move method in the organism class */
 @Test
 public void testMove() {
   Cell middle = new Cell(2, 2);
   system.add(rabbit, middle);
   rabbit.move(middle, system);
   system.findFirstEmptyNeighbor(middle, 0);
   String now = "xxMxxxxxx";
   assertEquals(now, printX());
 }
コード例 #3
0
 /** Tests the breed method in the organism class */
 @Test
 public void testBreed() {
   assertEquals(0, rabbit.getTimeSinceLastBreed());
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   rabbit.incrementTimeSinceLastBreed();
   assertEquals(7, rabbit.getTimeSinceLastBreed());
   Cell middle = new Cell(2, 2);
   Cell west = new Cell(1, 2);
   system.add(rabbit, middle);
   assertEquals(true, rabbit.breed(middle, system));
 }