From ca4da0b0200e99dcab7041925795a3695dda5dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Guill=C3=B3?= Date: Tue, 27 Feb 2024 11:05:45 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Definici=C3=B3n=20del=20archivo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Roadmap/09 - HERENCIA/java/pguillo02.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Roadmap/09 - HERENCIA/java/pguillo02.java diff --git a/Roadmap/09 - HERENCIA/java/pguillo02.java b/Roadmap/09 - HERENCIA/java/pguillo02.java new file mode 100644 index 0000000000..e69de29bb2 From ef439eaa341d49170d1c1b0bb2a67c1ecb1092e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Guill=C3=B3?= Date: Tue, 27 Feb 2024 11:10:51 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Definici=C3=B3n=20de=20la=20clase=20padre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Roadmap/09 - HERENCIA/java/pguillo02.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Roadmap/09 - HERENCIA/java/pguillo02.java b/Roadmap/09 - HERENCIA/java/pguillo02.java index e69de29bb2..cf96375797 100644 --- a/Roadmap/09 - HERENCIA/java/pguillo02.java +++ b/Roadmap/09 - HERENCIA/java/pguillo02.java @@ -0,0 +1,15 @@ +class Animal{ + private final String name; + private final int peso; + private 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(){} + +} + From 7605ca0122c8eaf6ce990bb73f073509194777d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Guill=C3=B3?= Date: Tue, 27 Feb 2024 11:16:47 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Definici=C3=B3n=20de=20la=20clase=20hijo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Roadmap/09 - HERENCIA/java/pguillo02.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Roadmap/09 - HERENCIA/java/pguillo02.java b/Roadmap/09 - HERENCIA/java/pguillo02.java index cf96375797..9b6b5f0431 100644 --- a/Roadmap/09 - HERENCIA/java/pguillo02.java +++ b/Roadmap/09 - HERENCIA/java/pguillo02.java @@ -1,7 +1,7 @@ class Animal{ - private final String name; - private final int peso; - private final int tamaño; + final String name; + final int peso; + final int tamaño; public Animal(String name, int peso, int tamaño){ this.name = name; @@ -10,6 +10,19 @@ public Animal(String name, int peso, int tamaño){ } 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); + } } From 9e5d234139c336f5063081b1239cd3962d70a3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Guill=C3=B3?= Date: Tue, 27 Feb 2024 11:21:55 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Definici=C3=B3n=20y=20prueba?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Roadmap/09 - HERENCIA/java/pguillo02.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Roadmap/09 - HERENCIA/java/pguillo02.java b/Roadmap/09 - HERENCIA/java/pguillo02.java index 9b6b5f0431..9531e67750 100644 --- a/Roadmap/09 - HERENCIA/java/pguillo02.java +++ b/Roadmap/09 - HERENCIA/java/pguillo02.java @@ -26,3 +26,10 @@ public void sound(){ } } +public class pguillo02 { + + public static void main(String args[]){ + Gato g = new Gato("Gato", 22, 22, "Miau"); + g.sound(); + } +}