Created
July 4, 2015 01:57
-
-
Save rafaelmv/2bf36d163fce97725aaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mamifero { | |
private int patas; | |
private String nombre; | |
public void imprimirPatas() { | |
System.out.println(nombre + ” tiene ” + patas + ” patas\n”); | |
} | |
public Mamifero(String nombre, int patas) { | |
this.nombre = nombre; | |
this.patas = patas; | |
} | |
} | |
public class Perro extends Mamifero { | |
public Perro(String nombre){ | |
super(nombre, 4); | |
} | |
} | |
public class Gato extends Mamifero { | |
public Gato(String nombre){ | |
super(nombre, 4); | |
} | |
} | |
public class CreaPerro { | |
public static void main(String [] args) { | |
Perro bobi = new Perro(“Bobi”); | |
bobi.imprimirPatas(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment