-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2034 from pguillo02/main
#9 - Java
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
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
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(); | ||
} | ||
} |