Entry 3642

interfaces

   

Submitted by nddrylliog on April 24, 2010 at 12:48 a.m.
Language: Ooc. Code size: 450 bytes.

Representable: interface {
    toString: func -> String
}


Dog: class implements Representable {
    growl: func {}

    toString: func -> String { "Dog!" }
    run: func {}
}


Cat: class implements Representable {
    meowl: func {}

    beLazy: func {}
    toString: func -> String { "Cat!" }
}


main: func {
    print(Dog new())
    print(Cat new())
}


print: func (r: Representable) {
    r toString() println()
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).