Last active
September 22, 2017 18:45
-
-
Save bkrmendy/4f220f1db291396f9b5a4f8f41ac7062 to your computer and use it in GitHub Desktop.
Pigeon.java from the Interfaces example project
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 flying; | |
import flying.Flying; | |
import flying.Coordinate; | |
public class Pigeon implements Flying { | |
public String name; | |
public int age; | |
public int weight; | |
public boolean isFlyingRightNow = false; //INTERFACE | |
public Pigeon(String name) { | |
age = 0; | |
this.name = name; | |
weight = 5; | |
System.out.println("A new pigeon is born, its called " + name); | |
} | |
public Pigeon(String name, int age, boolean inFlight){ | |
this.age = age; | |
this.name = name; | |
System.out.println("A new pigeon shows up, its called " + name); | |
} | |
void chirp(String message) { | |
System.out.println(this.name.toUpperCase() + ": " + message); | |
} | |
public void eat(){ | |
chirp("Eating right now"); | |
weight = weight + 1; | |
} | |
public void takeShit() { //Interface | |
chirp("Just took a shit"); | |
weight = weight - 1; | |
} | |
void takeOff() { //Interface | |
takeShit(); | |
chirp("I hate the ground"); | |
isFlyingRightNow = true; | |
} | |
void land() { //Interface | |
chirp("I'm tired as fuck"); | |
isFlyingRightNow = false; | |
eat(); | |
} | |
public void fly(Coordinate c){ | |
takeOff(); | |
chirp("I love flying!"); | |
weight = weight - 1; | |
land(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment