Example #1
0
 public static void advanceAll(ArrayList<Animal> animals) {
   ArrayList<Scorpion> scorps = new ArrayList<Scorpion>();
   for (Animal a : animals) {
     a.advance();
     if (a.getClass() == Scorpion.class) {
       scorps.add((Scorpion) a);
     }
   }
   for (Scorpion s : scorps) {
     if (s.unluckyFellow != -1) {
       System.out.println(animals.get(s.unluckyFellow).getName() + " has been stung!");
       animals.remove(s.unluckyFellow);
     }
   }
 }