-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemote.js
More file actions
78 lines (73 loc) · 1.9 KB
/
Remote.js
File metadata and controls
78 lines (73 loc) · 1.9 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
let Remote = function(id) {
this.id=id;
this.setPower = function(name) {
if (name.power === 'on') {
name.power = 'off';
} else {
name.power = 'on';
}
};
this.setVolum = function (plus) {
if (plus) {
tivi.volum++;
}
else {
tivi.volum--;
}
};
}
let Tivi = function(power, status, volum, channel) {
this.power=power;
this.volum=volum;
this.channel=channel;
this.status=status;
this.getChannel= function() {
this.channel=channel;
};
this.getStatus = function() {
this.status = 'TV:' + this.power + 'Playing channel:' + this.channel + 'Volum:' + this.volum;
return this.status;
}
};
function turnonoff() {
remote1.setPower(tivi);
document.getElementById('result').innerHTML = '';
document.getElementById('result').innerHTML += tivi.power + '<br>';
}
function Volum(plus) {
if (tivi.power === 'on') {
remote1.setVolum(plus);
document.getElementById('result').innerHTML = '';
document.getElementById('result').innerHTML += 'volumn '+tivi.volum + '<br>';
}
else {
printPoweroff();
}
}
function setChannel(channel) {
if (tivi.power === 'on') {
tivi.getChannel(channel);
checkstatus();
}
else {
printPoweroff();
}
}
function printPoweroff() {
document.getElementById('result').innerHTML += 'TV ' + tivi.power;
}
function checkstatus() {
if (tivi.power === 'on') {
document.getElementById('result').innerHTML += tivi.getStatus() + '<br>';
}
else {
printPoweroff();
}
}
let idRemote = 1;
let remote1 = new Remote(idRemote);
let statusTivi = '';
let channelTivi=2;
let volumTivi = 50;
let powerTivi = 'off';
let tivi = new Tivi(powerTivi, statusTivi, volumTivi, channelTivi);