Beispiel #1
0
 /**
  * This method makes the worm eat food.
  *
  * @post When the food gets eaten the radius of the worm will increas with 10%. | new.getRadius()
  *     == old.getRadius() * 1.1
  * @post When the food gets eaten the worm will be placed to the nearest adjecent location. |
  *     world.isAdjacent(xpos, ypos , radius) == true
  * @post When the food gets eaten this food object will de removed from the world. | (!
  *     (this.getWorld()).hasAsObject(food))
  */
 @Raw
 public void consumeFood() {
   double xpos = this.getXpos();
   double ypos = this.getYpos();
   Food food = this.overlappingFood();
   if (!(food == null)) {
     this.setRadius(this.getRadius() * 1.1);
     this.setNearestAdjacent(xpos, ypos);
     food.unsetWorld();
   }
 }