1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| var MotionInfo = function( name ){
this.texte = name;
};
MotionInfo.prototype.setTexte = function( str ){
this.texte = str;
};
MotionInfo.prototype.getTexte = function( str ){
return this.texte;
};
var MotionHRMInfo = function( name, nombre ){
MotionInfo.call( this, name );
this.nombre = nombre;
};
MotionHRMInfo.prototype = Object.create( MotionInfo.prototype );
MotionHRMInfo.prototype.setNombre = function( n ){
this.nombre = n;
};
MotionHRMInfo.prototype.getNombre = function( n ){
return this.nombre;
};
var ObjMI = new MotionInfo( "Pierre" ),
ObjHRMMI = new MotionHRMInfo( "Hector", 22 );
// debug, console, touche F12
console.log( "ObjMI = ", ObjMI );
console.log( "ObjHRMMI = ", ObjHRMMI );
console.log( "ObjHRMMI instanceof MotionInfo = ", ObjHRMMI instanceof MotionInfo );
ObjMI.setTexte( "Jean" );
ObjHRMMI.setNombre( 42 );
console.log( "ObjMI.getTexte() = ", ObjMI.getTexte() );
console.log( "ObjHRMMI.getTexte() = ", ObjHRMMI.getTexte() );
console.log( "ObjHRMMI.getNombre() = ", ObjHRMMI.getNombre() ); |
Partager