X Tutup
Skip to content

Commit 91ea24e

Browse files
committed
Сделал task01
1 parent 7767348 commit 91ea24e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

task01.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
</head>
7+
<body>
8+
<script>
9+
'use strict'
10+
class Obj{
11+
constructor(){
12+
this.unit = 0
13+
this.tens = 0
14+
this.hunders = 0
15+
}
16+
get vNum(){
17+
return 'hunders:'+this.hunders+'; tens: '+this.tens+'; unit: '+this.unit
18+
}
19+
set vNum(num){
20+
if(Number.isInteger(num) && num <= 999){
21+
let str_num = num.toString();
22+
for(let i=0;i < str_num.length ;i++){
23+
let pos = str_num.length-1-i
24+
switch(i){
25+
case 0: this.unit = parseInt(str_num.charAt(pos))
26+
break
27+
case 1: this.tens = parseInt(str_num.charAt(pos))
28+
break
29+
case 2: this.hunders = parseInt(str_num.charAt(pos))
30+
break
31+
}
32+
}
33+
} else {
34+
throw new Error("Error , the entered number does not satisfy the conditions");
35+
}
36+
}
37+
}
38+
39+
let o1 = new Obj
40+
o1.vNum = 188.1
41+
console.log(o1.vNum)
42+
</script>
43+
</body>
44+
</html>

0 commit comments

Comments
 (0)
X Tutup