-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay07_OOPLogicWithStatic.js
48 lines (23 loc) · 1.05 KB
/
Day07_OOPLogicWithStatic.js
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
//Using OOP concept inJS, Create a Square class
// You need just one param for the constructor => width
//when we initialize, we need to initialize 2 params in the class => width , heigth
//generate a function/ method to get the area odf the square
//generate also a toString method to see the description for the values
class Square {
constructor(width){
this.width = width;
this.heigth = width;
}
area(){
return this.width * this.heigth;
}
toString(){
return `The width is: ${this.width} and the heigth is : ${this.heigth}`
}
static isValidDimentions(a,b){
return a.width * a.heigth === b.width * b.heigth;
}
}
let square1 = new Square(5);
let square2 = new Square(5);
console.log(Square.isValidDimentions(square1,square2));