Skip to content

Instantly share code, notes, and snippets.

@bkrmendy
Last active September 22, 2017 18:45
Show Gist options
  • Save bkrmendy/2e1520e037b5cb287a92024bae79db1a to your computer and use it in GitHub Desktop.
Save bkrmendy/2e1520e037b5cb287a92024bae79db1a to your computer and use it in GitHub Desktop.
Boeing.java from the Interfaces example project
package flying;
import flying.Flying;
import flying.Coordinate;
public class Boeing implements Flying {
public static int serial = 1;
public int number;
public int passengerCount;
public double fuelAmount;
public boolean isFlyingRightNow = false; //INTERFACE
public Boeing(int passengerCount) {
this.number = serial;
serial = serial + 1;
this.passengerCount = passengerCount;
System.out.println("Flight no. " + number + " fresh out of the factory!");
}
void log(String message) {
System.out.println("BOEING #" + this.number + ": " + message);
}
void refuel(){
this.fuelAmount = 100;
log("Refueled successfully");
}
void birthOnBoard(){
passengerCount = passengerCount + 1;
log("A baby is born in-flight!");
}
void takeOff(){
refuel();
log("Ladies and gentlemen, about to take off");
}
public void land(){
log("Ladies and gentlemen, we've arrived!");
}
public void fly(Coordinate c){
takeOff();
fuelAmount = fuelAmount - 80;
log("This is your captain speaking, we've taken off successfully");
land();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment