forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTV.java
More file actions
executable file
·54 lines (52 loc) · 1.47 KB
/
TV.java
File metadata and controls
executable file
·54 lines (52 loc) · 1.47 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
/* */ package ch09;
/* */
/* */ public class TV {
/* 4 */ int channel = 1;
/* 5 */ int volumeLevel = 1;
/* */
/* */
/* */ boolean on = false;
/* */
/* */
/* */ public void turnOn() {
/* 12 */ this.on = true;
/* */ }
/* */
/* */ public void turnOff() {
/* 16 */ this.on = false;
/* */ }
/* */
/* */ public void setChannel(int newChannel) {
/* 20 */ if (this.on && newChannel >= 1 && newChannel <= 120)
/* 21 */ this.channel = newChannel;
/* */ }
/* */
/* */ public void setVolume(int newVolumeLevel) {
/* 25 */ if (this.on && newVolumeLevel >= 1 && newVolumeLevel <= 7)
/* 26 */ this.volumeLevel = newVolumeLevel;
/* */ }
/* */
/* */ public void channelUp() {
/* 30 */ if (this.on && this.channel < 120)
/* 31 */ this.channel++;
/* */ }
/* */
/* */ public void channelDown() {
/* 35 */ if (this.on && this.channel > 1)
/* 36 */ this.channel--;
/* */ }
/* */
/* */ public void volumeUp() {
/* 40 */ if (this.on && this.volumeLevel < 7)
/* 41 */ this.volumeLevel++;
/* */ }
/* */
/* */ public void volumeDown() {
/* 45 */ if (this.on && this.volumeLevel > 1)
/* 46 */ this.volumeLevel--;
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch09/TV.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/