July 2011
Intermediate to advanced
276 pages
5h 11m
English
But wait, we can do even more with Implements and Extends! Prepare to see them used simultaneously.
Starting off from where our last recipe left off will get us ready.
<h1>Speeds Before</h1>
<div id="before"></div>
<h1>Speeds After</h1>
<div id="after"></div>
// create two classes from the base Class
var Car = new Class({
showSpeed: function() { return 0; }
});
var SportyEngine = new Class({
speed: 10,
showSpeed: function() { return this.speed; }
});
// Extend one, Implement the other
var Corvette = new Class({
Extends: Car,
speed: 1,
showSpeed: function() {
// this.parent calls the overridden class
return this.parent()+1;
}
});
In this example, we want ...