-
Notifications
You must be signed in to change notification settings - Fork 0
/
OopsTest.java
183 lines (135 loc) · 3.97 KB
/
OopsTest.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package com.example.selfprogrammingtest;
abstract class Machine {
int weight;
void start() {
System.out.println("machine is running");
}
}
abstract class ElectronicDevice extends Machine {
String colors;
int dimension[];
}
class Camera {
private String Compny;
private int megaPixel;
public Camera(String compny, int megaPixel) {
Compny = compny;
this.megaPixel = megaPixel;
}
void run() {
System.out.println(this.Compny + " " + this.megaPixel + " " + " camera is running");
}
}
class AudioDevice {
void run() {
System.out.println("Audio player is running");
}
}
class SimCard {
private String compny;
public SimCard(String compny) {
this.compny = compny;
}
void run() {
System.out.println(this.compny + " " + "sim card is running");
}
}
class ExternalMemory {
private int memory;
public ExternalMemory(int memory) {
this.memory = memory;
}
void run() {
System.out.println(this.memory + " " + " Gb is external memory is running");
}
}
class TouchScreen {
private String compny;
private String resolution;
public TouchScreen(String compny, String resolution) {
this.compny = compny;
this.resolution = resolution;
}
void run() {
System.out.println(this.compny + " " + this.resolution + " Touch screen is running");
}
}
interface CameraFeatures {
void cameraFeatureName();
}
interface Webbrowser {
void webBrowserName();
}
abstract class SmartPhone extends ElectronicDevice implements CameraFeatures, Webbrowser {
String IMEI_Number;
}
interface MobileOs {
void OsName();
}
abstract class AndroidMobile extends SmartPhone implements MobileOs {
public void webBrowserName() {
System.out.println("Chrome browser is running");
}
public void OsName() {
System.out.println("Android Os is running");
}
}
interface ThirdpartyUi {
void UiFeatures();
}
class SamsungGalaxy8 extends AndroidMobile implements ThirdpartyUi {
int weight = 200;
String colors = "silver";
int[] dimension = {120, 70, 100};
private SimCard simCard;
private ExternalMemory externalMemory;
private final String IMEI_Number = "11223344556677";
private final Camera camera;
private final AudioDevice audioDevice;
private final TouchScreen touchScreen;
SamsungGalaxy8(SimCard simCard, ExternalMemory externalMemory) {
this.simCard = simCard;
this.externalMemory = externalMemory;
this.camera = new Camera("Sony", 48);
this.audioDevice = new AudioDevice();
this.touchScreen = new TouchScreen("Mi LED Screen", "Full HD");
}
void start() {
System.out.println("mobile is started");
this.OsName();
this.webBrowserName();
this.touchScreen.run();
}
@Override
public void cameraFeatureName() {
System.out.println("Samsung Camera feature is running");
}
@Override
public void UiFeatures() {
System.out.println("Samsung touch ui feature is running");
}
void startCamera() {
this.cameraFeatureName();
this.camera.run();
}
void startBrowser() {
this.webBrowserName();
}
void startAudio() {
this.audioDevice.run();
}
String getIMEI() {
return this.IMEI_Number;
}
}
public class OopsTest {
public static void main(String[] args) {
SimCard simCard = new SimCard("Airtel");
ExternalMemory externalMemory = new ExternalMemory(128);
SamsungGalaxy8 samsungGalaxy8 = new SamsungGalaxy8(simCard, externalMemory);
samsungGalaxy8.start();
samsungGalaxy8.startAudio();
samsungGalaxy8.startBrowser();
samsungGalaxy8.startCamera();
}
}