From c99b42e5b5063b7ad2df25bdfab3c7e358821f31 Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Mon, 27 Feb 2023 19:41:34 +0100 Subject: [PATCH 1/6] First commit --- Eagle.java | 36 +++++++++++++++++++++++++++++++++++- Fly.java | 11 +++++++++++ Nature.java | 18 +++++++++--------- 3 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 Fly.java diff --git a/Eagle.java b/Eagle.java index d0e8799..6ffeaeb 100644 --- a/Eagle.java +++ b/Eagle.java @@ -1,4 +1,4 @@ -public class Eagle extends Bird { +public class Eagle extends Bird implements Fly { private boolean flying; private int altitude; @@ -21,4 +21,38 @@ public boolean isFlying() { public String sing() { return "Screech!"; } + + @Override + public void takeOff(){ + System.out.println(this.getName() + " takes off in the sky."); + } + + int alt = 0; + + @Override + public void ascend(int distance){ + System.out.println(this.getName() + " flies upward, altitude : " + (alt+distance)); + alt = alt + distance; + } + + @Override + public void glide(){ + System.out.println("It flides into the air."); + } + + @Override + public void descend(int distance){ + System.out.println(this.getName() + " flies downward, altitude : " + (alt-distance)); + alt = alt - distance; + } + + @Override + public void land(){ + // return (alt > 1) ? System.out.println(this.getName() + " is too high, it can't lands.") : System.out.println(this.getName() + " lands on the ground."); + if (alt > 1){ + System.out.println(this.getName() + " is too high, it can't lands."); + } else { + System.out.println(this.getName() + " lands on the ground."); + } + } } diff --git a/Fly.java b/Fly.java new file mode 100644 index 0000000..be3dbf0 --- /dev/null +++ b/Fly.java @@ -0,0 +1,11 @@ +public interface Fly { + void takeOff(); + + void ascend(int distance); + + void glide(); + + void descend(int distance); + + void land(); +} \ No newline at end of file diff --git a/Nature.java b/Nature.java index fe104f5..b7185ae 100644 --- a/Nature.java +++ b/Nature.java @@ -3,17 +3,17 @@ public class Nature { public static void main(String[] args) { Penguin pingou = new Penguin("Pingou"); - pingou.dive(); - pingou.swimDown(3); - pingou.swimUp(1); - pingou.swimDown(4); - pingou.swimUp(5); - pingou.swimUp(1); - pingou.getOut(); + // pingou.dive(); + // pingou.swimDown(3); + // pingou.swimUp(1); + // pingou.swimDown(4); + // pingou.swimUp(5); + // pingou.swimUp(1); + // pingou.getOut(); Eagle hawkeye = new Eagle("Hawkeye"); // TODO : uncomment the following code in order to test it - /* + hawkeye.takeOff(); hawkeye.ascend(120); hawkeye.ascend(30); @@ -22,6 +22,6 @@ public static void main(String[] args) { hawkeye.land(); hawkeye.descend(9); hawkeye.land(); - */ + } } From 25d9a917b0e95d288827f872d4ed8b28affbb185 Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Mon, 27 Feb 2023 19:47:22 +0100 Subject: [PATCH 2/6] Second commit --- Eagle.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Eagle.java b/Eagle.java index 6ffeaeb..9212123 100644 --- a/Eagle.java +++ b/Eagle.java @@ -30,9 +30,9 @@ public void takeOff(){ int alt = 0; @Override - public void ascend(int distance){ - System.out.println(this.getName() + " flies upward, altitude : " + (alt+distance)); - alt = alt + distance; + public void ascend(int altitude){ + this.altitude += altitude; + System.out.println(this.getName() + " flies upward, altitude : " + this.altitude); } @Override @@ -41,9 +41,9 @@ public void glide(){ } @Override - public void descend(int distance){ - System.out.println(this.getName() + " flies downward, altitude : " + (alt-distance)); - alt = alt - distance; + public void descend(int altitude){ + this.altitude -= altitude; + System.out.println(this.getName() + " flies downward, altitude : " + this.altitude); } @Override From 9761d8013f5fe89fd85946dd072788862aef62ea Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Mon, 27 Feb 2023 19:47:54 +0100 Subject: [PATCH 3/6] Joie --- Eagle.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Eagle.java b/Eagle.java index 9212123..6dd5c4b 100644 --- a/Eagle.java +++ b/Eagle.java @@ -27,7 +27,6 @@ public void takeOff(){ System.out.println(this.getName() + " takes off in the sky."); } - int alt = 0; @Override public void ascend(int altitude){ From 0110d1c3a6c82a4bac0cde908adbb0dea49a7ad4 Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Mon, 27 Feb 2023 19:48:32 +0100 Subject: [PATCH 4/6] Joie 2 --- Eagle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eagle.java b/Eagle.java index 6dd5c4b..e04a52f 100644 --- a/Eagle.java +++ b/Eagle.java @@ -48,7 +48,7 @@ public void descend(int altitude){ @Override public void land(){ // return (alt > 1) ? System.out.println(this.getName() + " is too high, it can't lands.") : System.out.println(this.getName() + " lands on the ground."); - if (alt > 1){ + if (this.altitude > 1){ System.out.println(this.getName() + " is too high, it can't lands."); } else { System.out.println(this.getName() + " lands on the ground."); From a17e4f95edba4b94094366e8e1561ad9fa437497 Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Mon, 27 Feb 2023 20:04:44 +0100 Subject: [PATCH 5/6] LA TERNAIRE --- Eagle.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Eagle.java b/Eagle.java index e04a52f..f03b22e 100644 --- a/Eagle.java +++ b/Eagle.java @@ -47,11 +47,6 @@ public void descend(int altitude){ @Override public void land(){ - // return (alt > 1) ? System.out.println(this.getName() + " is too high, it can't lands.") : System.out.println(this.getName() + " lands on the ground."); - if (this.altitude > 1){ - System.out.println(this.getName() + " is too high, it can't lands."); - } else { - System.out.println(this.getName() + " lands on the ground."); - } + System.out.println(this.altitude > 1 ? this.getName() + " is too high, it can't lands." : this.getName() + " lands on the ground."); } } From 7e6f1fcacadd59cf14e40659a1f29162fcfab373 Mon Sep 17 00:00:00 2001 From: Nicolas Chapgier Date: Tue, 28 Feb 2023 10:23:20 +0100 Subject: [PATCH 6/6] add comment to change branch --- Nature.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Nature.java b/Nature.java index b7185ae..ba57439 100644 --- a/Nature.java +++ b/Nature.java @@ -1,5 +1,13 @@ public class Nature { + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + // BIEN CHANGER DE BRANCH ET SE PLACER SUR MAIN + public static void main(String[] args) { Penguin pingou = new Penguin("Pingou");