2010-02-28 00:40:53 +00:00
|
|
|
class Animal
|
2010-11-21 17:38:27 +00:00
|
|
|
constructor: (@name) ->
|
2010-07-29 04:51:35 +00:00
|
|
|
|
2010-02-28 00:40:53 +00:00
|
|
|
move: (meters) ->
|
|
|
|
alert @name + " moved " + meters + "m."
|
2010-02-09 12:59:48 +00:00
|
|
|
|
2010-02-28 00:40:53 +00:00
|
|
|
class Snake extends Animal
|
|
|
|
move: ->
|
|
|
|
alert "Slithering..."
|
|
|
|
super 5
|
2010-02-09 12:59:48 +00:00
|
|
|
|
2010-02-28 00:40:53 +00:00
|
|
|
class Horse extends Animal
|
|
|
|
move: ->
|
|
|
|
alert "Galloping..."
|
|
|
|
super 45
|
2009-12-21 16:41:45 +00:00
|
|
|
|
2010-07-29 04:51:35 +00:00
|
|
|
sam = new Snake "Sammy the Python"
|
|
|
|
tom = new Horse "Tommy the Palomino"
|
2009-12-21 16:41:45 +00:00
|
|
|
|
|
|
|
sam.move()
|
|
|
|
tom.move()
|
2009-12-24 06:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|