1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/documentation/coffee/classes.coffee

26 lines
353 B
CoffeeScript
Raw Normal View History

class Animal
2010-11-21 12:38:27 -05:00
constructor: (@name) ->
2010-07-29 00:51:35 -04:00
move: (meters) ->
alert @name + " moved #{meters}m."
class Snake extends Animal
move: ->
alert "Slithering..."
super 5
class Horse extends Animal
move: ->
alert "Galloping..."
super 45
2009-12-21 11:41:45 -05:00
2010-07-29 00:51:35 -04:00
sam = new Snake "Sammy the Python"
tom = new Horse "Tommy the Palomino"
2009-12-21 11:41:45 -05:00
sam.move()
tom.move()
2009-12-24 01:22:41 -05:00