Initial commit

This commit is contained in:
valerpan 2026-07-18 23:59:42 +03:00
parent 47e1eb9506
commit 4d7a94e602
4 changed files with 3 additions and 4 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 = " мясом. ";

View File

@ -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();
} }