-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ2.js
More file actions
36 lines (28 loc) · 655 Bytes
/
Q2.js
File metadata and controls
36 lines (28 loc) · 655 Bytes
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
// Convert the UML diagram to Typescript class. - use number for double
class Circle {
constructor(radius = 1.0, color = "red") {
this.radius = radius;
this.color = color;
}
getRadius() {
return this.radius;
}
setRadius(radius) {
this.radius = radius;
}
getColor() {
return this.color;
}
setColor(color) {
this.color = color;
}
toString() {
return `Circle[radius=${this.radius},color=${this.color}]`;
}
getArea() {
return Math.PI * this.radius ** 2;
}
getCircumference() {
return 2 * Math.PI * this.radius;
}
}