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
| function Batiment(name, width, height)
{
/* Attributes */
var _name = name;
var _width = width;
var _height = height;
/* Methods */
Batiment.prototype =
{
show : function()
{
alert("Name : " + _name + " ; size : [" + _width + "," + _height + "]");
}
/* Mutators */
setSize : function(width, height)
{
_width = parseInt(width);
_height = parseInt(height);
}
getWidth : function() { return _width; }
getHeight : function() { return _height; }
}
}
var myBat = new Batiment("test");
myBat.setPosition(10, 10);
myBat.show(); |
Partager