Created
February 8, 2015 21:33
-
-
Save kevinpet/f0ff497dd88537bfbf62 to your computer and use it in GitHub Desktop.
OO Java
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
abstract class OoFoo { | |
abstract void handle(); | |
static class Bar extends OoFoo { | |
private int bar; | |
private Bar(int bar) { | |
this.bar = bar; | |
} | |
@Override | |
void handle() { | |
System.out.println("I have " + bar + " bars"); | |
} | |
} | |
static class Baz extends OoFoo { | |
private String baz; | |
private Baz(String baz) { | |
this.baz = baz; | |
} | |
@Override | |
void handle() { | |
System.out.println("I have the " + baz + " baz"); | |
} | |
} | |
public static void main(String[] args) { | |
new Bar(42).handle(); | |
new Baz("Luhrmann").handle(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment