Last active
September 22, 2017 16:53
-
-
Save bkrmendy/20434d798686180961fa40ca8c8d5718 to your computer and use it in GitHub Desktop.
Main.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
import flying.Boeing; | |
import flying.Pigeon; | |
import flying.Coordinate; | |
import flying.Flying; | |
public class Main { | |
public static void main(String[] args) { | |
Boeing boeing1 = new Boeing(112); | |
Boeing boeing2 = new Boeing(108); | |
Pigeon joe = new Pigeon("joe"); | |
Coordinate new_york_city = new Coordinate(21.4, 33.5); | |
/* | |
A flying_object tömbbe olyan objektumokat lehet | |
tenni, amik implementálják a Flying interface-t. | |
*/ | |
Flying[] flying_objects = { boeing1, boeing2, joe }; | |
/* | |
A tömbben lévő objektumokat a típusuktól függetlenül tudjuk | |
kezelni, de csak azokat a függvényeket / változókat lehet használni, | |
amik az interface-ben specifikálva vannak. | |
*/ | |
for(Flying object : flying_objects) | |
object.fly(new_york_city); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment