2010-02-27 19:40:53 -05:00
|
|
|
class Animal
|
2010-11-21 12:38:27 -05:00
|
|
|
constructor: (@name) ->
|
2010-07-29 00:51:35 -04:00
|
|
|
|
2010-02-27 19:40:53 -05:00
|
|
|
move: (meters) ->
|
2011-06-08 19:38:12 -04:00
|
|
|
alert @name + " moved #{meters}m."
|
2010-02-09 07:59:48 -05:00
|
|
|
|
2010-02-27 19:40:53 -05:00
|
|
|
class Snake extends Animal
|
|
|
|
move: ->
|
|
|
|
alert "Slithering..."
|
|
|
|
super 5
|
2010-02-09 07:59:48 -05:00
|
|
|
|
2010-02-27 19:40:53 -05:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|