хорошо, хорошо, буду повторять 3 переменные в каждом классе.. Но почему нельзя наследованием?
package com.javarush.task.task05.task0527;
/*
Том и Джерри
*/
public class Solution {
public static void main(String[] args) {
Mouse jerryMouse = new Mouse("Jerry", 12, 5);
Cat tomCat = new Cat("Tom",80,100);
Dog untitled = new Dog("Sharik", 100, 40);
//напишите тут ваш код
}
public static class Animal {
String name;
int height;
int tail;
}
public static class Mouse extends Animal {
public Mouse(String name, int height, int tail) {
this.name = name;
this.height = height;
this.tail = tail;
}
}
public static class Cat extends Animal {
public Cat(String name, int height, int tail) {
this.name = name;
this.height = height;
this.tail = tail;
}
}
public static class Dog extends Animal {
public Dog(String name, int height, int tail) {
this.name = name;
this.height = height;
this.tail = tail;
}
}
}