Initial commit
This commit is contained in:
parent
47e1eb9506
commit
4d7a94e602
@ -15,6 +15,7 @@ public abstract class Carnivore extends Animal{
|
|||||||
int satiety = this.getSatiety();
|
int satiety = this.getSatiety();
|
||||||
if (food instanceof Meat) {
|
if (food instanceof Meat) {
|
||||||
satiety += food.getEnergy();
|
satiety += food.getEnergy();
|
||||||
|
this.setSatiety(satiety);
|
||||||
System.out.println("Животное ест.");
|
System.out.println("Животное ест.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -15,6 +15,7 @@ public class Herbivore extends Animal{
|
|||||||
int satiety = this.getSatiety();
|
int satiety = this.getSatiety();
|
||||||
if (food instanceof Grass) {
|
if (food instanceof Grass) {
|
||||||
satiety += food.getEnergy();
|
satiety += food.getEnergy();
|
||||||
|
this.setSatiety(satiety);
|
||||||
System.out.println("Животное ест.");
|
System.out.println("Животное ест.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package employee;
|
package employee;
|
||||||
|
|
||||||
import animals.Animal;
|
import animals.Animal;
|
||||||
import animals.Swim;
|
|
||||||
import animals.Voice;
|
import animals.Voice;
|
||||||
import food.Food;
|
import food.Food;
|
||||||
import food.Grass;
|
import food.Grass;
|
||||||
@ -19,7 +18,7 @@ public class Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void feed(Animal animal, Food food){
|
public void feed(Animal animal, Food food){
|
||||||
String type = new String();
|
String type = "";
|
||||||
|
|
||||||
if (food instanceof Grass) type = " травой. ";
|
if (food instanceof Grass) type = " травой. ";
|
||||||
if (food instanceof Meat) type = " мясом. ";
|
if (food instanceof Meat) type = " мясом. ";
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package food;
|
package food;
|
||||||
|
|
||||||
import javax.naming.Name;
|
|
||||||
|
|
||||||
public abstract class Food {
|
public abstract class Food {
|
||||||
public abstract int getEnergy();
|
public abstract int getEnergy();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user