Skip to content

Instantly share code, notes, and snippets.

@jnegre jnegre/You.java

Created Feb 17, 2012
Embed
What would you like to do?
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
You can’t perform that action at this time.