Skip to content

Instantly share code, notes, and snippets.

@rafaelmv
Created July 4, 2015 01:57
Show Gist options
  • Save rafaelmv/2bf36d163fce97725aaa to your computer and use it in GitHub Desktop.
Save rafaelmv/2bf36d163fce97725aaa to your computer and use it in GitHub Desktop.
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