Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion Eagle.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Eagle extends Bird {
public class Eagle extends Bird implements Fly {

private boolean flying;
private int altitude;
Expand All @@ -21,4 +21,32 @@ public boolean isFlying() {
public String sing() {
return "Screech!";
}

@Override
public void takeOff(){
System.out.println(this.getName() + " takes off in the sky.");
}


@Override
public void ascend(int altitude){
this.altitude += altitude;
System.out.println(this.getName() + " flies upward, altitude : " + this.altitude);
}

@Override
public void glide(){
System.out.println("It flides into the air.");
}

@Override
public void descend(int altitude){
this.altitude -= altitude;
System.out.println(this.getName() + " flies downward, altitude : " + this.altitude);
}

@Override
public void land(){
System.out.println(this.altitude > 1 ? this.getName() + " is too high, it can't lands." : this.getName() + " lands on the ground.");
}
}
11 changes: 11 additions & 0 deletions Fly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public interface Fly {
void takeOff();

void ascend(int distance);

void glide();

void descend(int distance);

void land();
}
26 changes: 17 additions & 9 deletions Nature.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
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");
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);
Expand All @@ -22,6 +30,6 @@ public static void main(String[] args) {
hawkeye.land();
hawkeye.descend(9);
hawkeye.land();
*/

}
}