Last active
December 15, 2015 04:49
-
-
Save codemaniac/5204067 to your computer and use it in GitHub Desktop.
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
abstract class Person { | |
String name; | |
Person(String name) { | |
this.name = name; | |
} | |
} | |
interface ICatchPlayer<T extends Throwable> { | |
void throww(T object); | |
} | |
abstract class CatchPlayablePerson<T extends Throwable> | |
extends Person implements ICatchPlayer<T> { | |
CatchPlayablePerson<T> target; | |
public CatchPlayablePerson(String name) { | |
super(name); | |
} | |
} | |
final class Ball extends Throwable {} | |
final class BallCatchPlayablePerson | |
extends CatchPlayablePerson<Ball> { | |
public BallCatchPlayablePerson(String name) { | |
super(name); | |
} | |
@Override | |
public void throww(Ball ball) { | |
try { | |
throw ball; | |
} catch (Ball b) { | |
target.throww(b); | |
} | |
} | |
} | |
public class CatchGame { | |
public static void main(String[] args) { | |
CatchPlayablePerson kittun = new BallCatchPlayablePerson("Kittun"); | |
CatchPlayablePerson kuala = new BallCatchPlayablePerson("Kuala"); | |
kittun.target = kuala; | |
kuala.target = kittun; | |
kittun.throww(new Ball()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment