Skip to content

Commit

Permalink
Merge pull request #2034 from pguillo02/main
Browse files Browse the repository at this point in the history
#9 - Java
  • Loading branch information
Roswell468 authored Feb 27, 2024
2 parents f0218ed + 9e5d234 commit 4e9fb90
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Roadmap/09 - HERENCIA/java/pguillo02.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Animal{
final String name;
final int peso;
final int tamaño;

public Animal(String name, int peso, int tamaño){
this.name = name;
this.tamaño = tamaño;
this.peso = peso;
}

public void sound(){}
}

class Gato extends Animal{
private final String sonido;

public Gato(String name, int peso, int tamaño, String sonido){
super(name, peso, tamaño);
this.sonido = sonido;
}

@Override
public void sound(){
System.out.println("El" + name + "suena" + sonido);
}
}

public class pguillo02 {

public static void main(String args[]){
Gato g = new Gato("Gato", 22, 22, "Miau");
g.sound();
}
}

0 comments on commit 4e9fb90

Please sign in to comment.