-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.js
58 lines (47 loc) · 994 Bytes
/
classes.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
49
50
51
52
53
54
class car{
constructor(color,brand){
this.color = color;
this.brand = brand;
}
set carcolor(y){
this.color = y;
}
get carcolor(){
return this.color;
}
}
let swift = new car("White","maruti");
console.log(swift);
swift.carcolor="red";
console.log(swift);
console.log(swift.carcolor);
var check = swift instanceof car;
console.log(check);
class shape{
constructor(name){
this.name = name;
}
set shapeName(sname){
this.name = sname;
}
get shapeName(){
return this.name;
}
}
class circle extends shape{
constructor(name,radius){
super(name);
this.radius = radius;
}
set cicleRadius(r){
this.radius = r;
}
get circleRadius(){
return this.radius;
}
calculate_area(){
return "Area of " + this.name + " is " + (3.14*this.radius*this.radius);
}
}
let c1 = new circle("circle",10);
console.log(c1.calculate_area());