Skip to content

Instantly share code, notes, and snippets.

@jnegre
Created February 17, 2012 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnegre/1853231 to your computer and use it in GitHub Desktop.
Save jnegre/1853231 to your computer and use it in GitHub Desktop.
package you;
import clowns.Clown;
import clowns.Volkswagen;
public class You {
private static class BandOfClowns extends Clown {
final int id;
final Volkswagen vw;
public BandOfClowns(int id, Volkswagen vw) {
System.out.println("One more clown, I'm #" + id);
this.id = id;
this.vw = vw;
}
public int hashCode() {
if (id != 1) {
vw.add(new BandOfClowns(id - 1, vw));
}
return super.hashCode();
}
}
public static void main(String args[]) {
Volkswagen vw = new Volkswagen();
vw.add(new BandOfClowns(20, vw));
vw.done();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment