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
| /* Batiment structure */
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 */
Batiment.prototype.setSize = function(width, height)
{
_width = parseInt(width);
_height = parseInt(height);
}
Batiment.prototype.getWidth = function() { return _width; }
Batiment.prototype.getHeight = function() { return _height; }
}
var myBat = new Batiment("test");
myBat.setPosition(10, 30);
myBat.setSize(20, 40);
myBat.show(); |
Partager