first, this is my code:
var rettangolo = {
rectX_top: 0,
recX_bottom: 0,
rectY_top: 0,
rectY_top: 0,
colpito: false,
colore: 'hsl(' + 360 * Math.random() + ', 50%, 50%)',
rettangolo: function() {
this.setRectX_top(0);
this.setRectX_bottom(0);
this.setRectY_top(0);
this.setRectY_top(0);
this.setColpito(false);
this.setColore('red');
},
setColpito: function(colpito) {
this.colpito = colpito;
},
setColore: function(colore) {
this.colore = colore;
},
setRectY_top: function(top) {
rectY_top = top;
},
setRectX_top: function(top) {
rectX_top = top;
},
setRectX_bottom: function(bottom) {
rectX_bottom = bottom;
},
setRectY_bottom: function(bottom) {
rectY_bottom = bottom;
},
<!-- GET METHODS -->
getColore: function() {
return this.colore;
},
getRectY_top: function() {
return this.rectY_top;
},
getColpito: function() {
return this.colpito;
},
getRectX_top: function() {
return this.rectX_top;
},
getRectX_bottom: function() {
return this.rectX_bottom;
},
getRectY_bottom: function() {
return this.rectY_bottom;
},
}
This is my class, and now I need to create multiple instances of this class. Is it possible? And if it is, how do you achieve it? (Plus, is it correct? notice that this is the first class I create as they never explained it at school). Thank you!