PATOS

Código del ejercicio con los patos

**Clase Super **
public class Ducks {
Ducks() {}

public void display()
{
System.out.println("Muestra el patito");
}

public void swing()
{
System.out.println("El patito nada");
}
}

Clase pato de hule
public class PatoHule extends Ducks implements Quackeable {
public PatoHule(){
super();
}

public void mostrar()
{
System.out.println("\nPato de Hule");
super.display();
super.swing();
quack();
}

public void quack()
{
System.out.println("Quack");
}
}

Pato Madera
public class PatoMadera extends Ducks{
PatoMadera(){
super();

}

public void mostrar(){
System.out.println("\nPato de Madera");
super.display();
super.swing();

}
}

Pato Read Head
public class ReadHeadDucks extends Ducks implements Flyable ,Quackeable{
ReadHeadDucks(){
super();
}

public void mostrar(){

System.out.println("\nReadHeadDucks");
super.display();
super.swing();
fly();
quack();

}

public void quack(){

System.out.println("Quack");

}

public void fly()
{

System.out.println("El patito vuela");
}
}

Pato Real
public class MallordDucks extends Ducks implements Quackeable ,Flyable {
MallordDucks(){
}

public void mostrar(){
System.out.println("\nMallordDucks");
super.display();
super.swing();
fly();
quack();
}

public void quack(){

System.out.println("Quack");

}

public void fly()
{

System.out.println("El patito vuela");
}
}

Interfaz Quackeable
public interface Quackeable {

public void quack();

}

Interfaz Fyable
public interface Flyable {

public void fly();
}

Clase de Prueba

public class Interfaz {

public static void main(String[] args) {

ReadHeadDucks pato = new ReadHeadDucks();//
pato.mostrar();

PatoHule pato1=new PatoHule();
pato1.mostrar();

PatoMadera pato2=new PatoMadera();
pato2.mostrar();

MallordDucks pato3=new MallordDucks();
pato3.mostrar();
}
}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License