-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTV.js
More file actions
58 lines (58 loc) · 1.18 KB
/
TV.js
File metadata and controls
58 lines (58 loc) · 1.18 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
class TV
{
constructor(brand)
{
this.brand=brand;
this.channel=80;
this.volume=20;
}
// set channel(c)
// {
// this.channel=c;
// }
reset()
{
this.channel=80;
this.volume=20;
}
changechannel(c)
{
if(c>=1 && c<=100)
this.channel=c;
else
console.log("Invalid Channel No");
}
increaseVol(v)
{
let newvol=this.volume+v;
if(newvol<=100)
this.volume=newvol;
else
console.log("Volume cannot be beyond 100");
}
decreaseVol(v)
{
let newvol=this.volume-v;
if(newvol>=0)
this.volume=newvol;
else
console.log("Volume cannot be below 0");
}
status()
{
console.log("Brand: "+this.brand+"\nCurrent Channel No: "+this.channel+"\nCurrent Volume: "+this.volume);
}
}
let tv1=new TV('Samsung');
tv1.status();
tv1.changechannel(50);
tv1.channel=10;
console.log("\nAfter increasing volume\n");
tv1.increaseVol(20);
tv1.status();
console.log("\nAfter decreasing volume")
tv1.decreaseVol(50);
tv1.status();
console.log("After Reset");
tv1.reset();
tv1.status();