Last active
September 22, 2017 18:45
-
-
Save bkrmendy/2e1520e037b5cb287a92024bae79db1a to your computer and use it in GitHub Desktop.
Boeing.java from the Interfaces example project
This file contains hidden or 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 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