0

Abstractization not working

What is wrong with that?? I tried several times but it definitely not works class Main { public static void main(String[] args) { Animal dog = new Dog(); Animal cat = new Cat(); dog.swim(); cat.swim(); dog.play(); cat.play(); } } interface Swimmer { void swim(); } interface Player { void play(); } //implement the Swimmer and the Player interfaces abstract class Animal implements Swimmer,Player{ } class Dog extends Animal { //Override the swim() and the play() methods void swim(){ System.out.println(" Dog is swimming"); } void play(){ System.out.println(" Dog is playing"); } } class Cat extends Animal { //Override the swim() and the play() methods void swim(){ System.out.println(" Cat is swimming"); } void play(){ System.out.println(" Cat is playing"); } }

26th May 2021, 12:16 PM
Remus Tanasa
3 ответов
+ 1
Thanks a lot for helping me!!!
26th May 2021, 1:32 PM
Remus Tanasa