Skip to content

Instantly share code, notes, and snippets.

@egonelbre
Last active December 10, 2015 08:18
Show Gist options
  • Select an option

  • Save egonelbre/4406978 to your computer and use it in GitHub Desktop.

Select an option

Save egonelbre/4406978 to your computer and use it in GitHub Desktop.
public class Battle<LionPlayer, BearPlayer> {
private LionPlayer Lion;
private BearPlayer Bear;
private void Lion$fight(){
System.out.println(Lion.getName() + ": meow...");
};
private void Bear$fight(){
System.out.println(Bear.getName() + ": grrr...");
}
private void Bear$touch(){
Bear$fight();
Bear.say();
Bear.say();
Lion$fight();
}
public Battle(LionPlayer lionPlayer, BearPlayer bearPlayer) {
Lion = lionPlayer;
Bear = bearPlayer;
Bear$touch();
}
}
@Context
public class Battle<LionPlayer, BearPlayer> {
@Role(LionPlayer)
private class Lion {
void fight(){
System.out.println(this.getName() + ": meow...");
}
}
@Role(BearPlayer)
private class Bear {
void fight(){
System.out.println(this.getName() + ": grrr...");
}
void touch(){
Bear.fight();
Bear.say();
this.say();
Lion.fight();
}
}
public Battle(LionPlayer lionPlayer, BearPlayer bearPlayer) {
Lion = lionPlayer;
Bear = bearPlayer;
Bear.touch();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment