forked from Ritikraja07/Java-problem-Open-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq6.java
82 lines (66 loc) · 1.86 KB
/
q6.java
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
79
80
81
82
import java.util.*;
// Interface for basic TV remote
interface TVRemote {
void powerOn();
void powerOff();
void changeChannel(int channel);
void volumeUp();
void volumeDown();
}
// Interface for smart TV remote extending TVRemote
interface SmartTvRemote extends TVRemote {
void openApp(String appName);
void browseInternet();
}
// Example implementation of the SmartTvRemote interface
class MySmartTvRemote implements SmartTvRemote {
int currentChannel = 1;
int currentVolume = 10;
@Override
public void powerOn() {
System.out.println("Smart TV is powered ON.");
}
@Override
public void powerOff() {
System.out.println("Smart TV is powered OFF.");
}
@Override
public void changeChannel(int channel) {
this.currentChannel = channel;
System.out.println("Channel changed to " + channel);
}
@Override
public void volumeUp() {
this.currentVolume++;
System.out.println("Volume increased to " + currentVolume);
}
@Override
public void volumeDown() {
this.currentVolume--;
System.out.println("Volume decreased to " + currentVolume);
}
@Override
public void openApp(String appName) {
System.out.println("Opening app: " + appName);
}
@Override
public void browseInternet() {
System.out.println("Browsing the internet on Smart TV.");
}
}
public class q6 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int c = in.nextInt();
// Using SmartTvRemote
SmartTvRemote Remote = new MySmartTvRemote();
Remote.powerOn();
Remote.changeChannel(c);
Remote.volumeUp();
Remote.browseInternet();
Remote.openApp("YouTube");
Remote.volumeDown();
Remote.powerOff();
in.close();
}
}