На сколько корректно примерное описание классов?
public static void main(String[] args){
Animal cat = new Cat(3,"Брсик");
Animal dog = new Dog(5,"Вульф");
List<Animal> myAnimal = Arrays.asList(cat, dog);
for (Animal animal : myAnimal) {
cat.eat();
dog.eat();
}
}
public interface Animal {
int getAGe();
String getName();
void walk();
void eat();
void sleep();
}
public abstract class Canidae implements Animal {
private final int age;
private final String name;
public Canidae(int age, String name) {
this.age = age;
this.name = name;
}
public int getAGe() {
return age;
}
public String getName() {
return name;
}
}
public abstract class Felidae implements Animal {
private final int age;
private final String name;
public Felidae(int age, String name) {
this.age = age;
this.name = name;
}
public int getAGe() {
return age;
}
public String getName() {
return name;
}
}
public class Dog extends Canidae {
public Dog(int age, String name) {
super(age, name);
}
public void walk() {
}
@Override
public void eat() {
System.out.println("Хрум");
}
public void sleep() {
}
}
public class Cat extends Felidae {
public Cat(int age, String name) {
super(age, name);
}
public void walk() {
}
public void eat() {
System.out.println("Ням");
}
public void sleep() {
}
}