html
html
1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<head>
<title>
class constructor
square rectangle
</title>
</head>
<body>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
body {
}
sup{font-size:9px;}
Enter to Rename, Shift+Enter to Preview
js
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
const
hight = prompt("Enter the hight of the rectangle.\nВведите высоту прямоугольника.") || screen.height,
width = prompt("Enter the width of the rectangle.\nВведите ширину прямоугольника.") || screen.width;
class Rectangle {
constructor(hight,width) {
this.hight = hight;
this.width = width;
}
get rectangle() {
return this.areaRectangle();
}
areaRectangle() {
let
sqrRect=this.hight*this.width;
return Math.round(sqrRect*100)/100;
}
}
const square = new Rectangle(hight,width);
document.write(
"<p>Width: ", square.width,
"<br>Height: ", square.hight,
"<br>Rectangle area = ",
square.areaRectangle(),
"m<sup>2</sup></p>"
);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run