Created
February 13, 2019 11:03
-
-
Save JHarry444/ae3ed48d86d348a9254f435b1a08e440 to your computer and use it in GitHub Desktop.
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
package main; | |
public abstract class Animal { | |
private int numLimbs; | |
private int numEyes; | |
public Animal(int numLimbs, int numEyes) { | |
this.numLimbs = numLimbs; | |
this.numEyes = numEyes; | |
} | |
public Animal() { | |
} | |
public abstract void eat(); | |
public abstract void breathe(); | |
public int getNumLimbs() { | |
return numLimbs; | |
} | |
public void setNumLimbs(int numLimbs) { | |
this.numLimbs = numLimbs; | |
} | |
public int getNumEyes() { | |
return numEyes; | |
} | |
public void setNumEyes(int numEyes) { | |
this.numEyes = numEyes; | |
} | |
} |
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
package main; | |
public class App { | |
public static void main(String[] args) { | |
Bird oz = new Ostrich(); | |
oz.fly(); | |
oz.eat(); | |
oz.breathe(); | |
System.out.println(oz.getNumEyes()); | |
System.out.println(oz.getNumLimbs()); | |
} | |
} |
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
package main; | |
public abstract class Bird extends Animal { | |
public Bird() { | |
super(4, 2); | |
} | |
public void fly() { | |
System.out.println("Flap Flap"); | |
} | |
@Override | |
public void breathe() { | |
// TODO Auto-generated method stub | |
System.out.println("#gasp#"); | |
} | |
@Override | |
public void eat() { | |
// TODO Auto-generated method stub | |
System.out.println("Scratch and Peck"); | |
} | |
} |
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
package main; | |
public class Ostrich extends Bird { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment