forked from barais/tpWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.js
More file actions
66 lines (57 loc) · 1.48 KB
/
model.js
File metadata and controls
66 lines (57 loc) · 1.48 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Implémenter ici les 4 classes du modèle.
// N'oubliez pas l'héritage !
function Drawing(){
this.forms = new Array();
this.count=0;
this.getCount = function(){
return this.count;
}.bind(this);
this.getForms = function() {
return this.forms;
}.bind(this);
this.addForms = function(form) {
this.forms.push(form);
}.bind(this);
this.removeForms = function(elm){
this.forms.splice(this.forms.indexOf(elm),1);
this.count--;
}.bind(this);
}
function Form(x1,y1,x2,y2,thick,color,form){
this.thick=thick;
this.color=color;
this.x1=x1;
this.y1=y1;
this.x2=x2;
this.y2=y2;
this.form=form;
this.getX1= function(){
return this.x1;
}.bind(this);
this.getY1= function(){
return this.y1;
}.bind(this);
this.getThick= function(){
return this.thick;
}.bind(this);
this.getColor= function(){
return this.color;
}.bind(this);
this.getX2= function(){
return this.x2;
}.bind(this);
this.getY2= function(){
return this.y2;
}.bind(this);
this.getForm= function(){
return this.form;
}.bind(this);
}
function Rectangle(x1,y1,width,height,thick,color){
Form.call(this,x1,y1,width,height,thick,color,"Rectangle");
};
Rectangle.prototype = new Form();
function Line(x1,y1,x2,y2,thick,color){
Form.call(this,x1,y1,x2,y2,thick,color,"Line");
};
Line.prototype = new Line();