Christmas Carols in Java

public abstract class Tree implements Comparable<Tree> {

    public int compareTo(Tree that) {
        if (this instanceof Holly) {
            if (that instanceof Holly) {
                return 0;
            } else {
                return 1;
            }
        } else if (that instanceof Holly)
            return -1;
        } else {
            return 0; // All other trees are equal, as per noble law
        }
    }
}

One Response to “Christmas Carols in Java”

  1. James Cranch Says:

    # a taste of Christmas in Python

    def dayOfChristmas(N):
    l = ["a partridge in a pear tree","two turtledoves","three french hens","four calling birds","five gold rings","six geese a-laying","seven swans a-swimming","eight maids a-milking","nine ladies dancing","ten lords a-leaping","eleven pipers piping","twelve drummers drumming"][0:N]
    l.reverse()
    for s in l:
    print s

Leave a Reply