Let's create an instance of a Dog
class by deploying the following the steps:
Create an HTML document for this. Use the following code taken from our
Dog
class.<html> <head> <script type="text/javascript" src="mootools-1.2.1-core-nc.js"> </script> <script type="text/javascript"> var Dog = new Class( { Implements : [ Options ], options : { name : 'Barkee', type : 'Poodle', age : 4 }, initialize : function( options ) { this.setOptions( options ); }, bark : function() { alert( this.options.name + ' is barking.' ); }, sit : function() { alert( this.options.name + ' is sitting.' ); } }); </script> </head> <body> </body> </html>
Apart from taking out the comments, referencing the MooTools framework, and putting in the basic tags for an HTML document, nothing has changed so far.
Create an instance of our
Dog
class, you can call the class instance anything you like, but I'll call mine simplymyDog...