Yah, my fault. Indeed I didn't have my prototype.js. And after I make
sure I have my prototype.js, and run it again, I still didn't see
anything and got 1 error in Mozila, saying:

sound is not defined

How do I go about it now? Below are the whole code:

<script>
var Animal = Class.create();

Animal.prototype = {
        initialize: function(name, sound) {
                this.name = name;
                this.sound = sound;
        },
        speak: function() {
        alert(name + " says: " + sound + "!");
        }
};

var snake = new Animal("Ringneck", "hissssssssss");
snake.speak();
// -> alerts "Ringneck says: hissssssssss!"

var Dog = Class.create();
Dog.prototype = Object.extend(new Animal(), {
        initialize: function(name) {
                this.name = name;
                this.sound = "woof";
        }
});

var fido = new Dog("Fido");
fido.speak();
// -> alerts "Fido says: woof!"
</script>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to