File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Led {
2
+ private int id ;
3
+ private String brand ;
4
+ private double price ;
5
+
6
+ public Led (int id , String brand , double price ) {
7
+ this .id = id ;
8
+ this .brand = brand ;
9
+ this .price = price ;
10
+ }
11
+
12
+ public double getPrice () {
13
+ return price ;
14
+ }
15
+
16
+ public String getBrand () {
17
+ return brand ;
18
+ }
19
+
20
+ public void setBrand (String brand ) {
21
+ this .brand = brand ;
22
+ }
23
+
24
+ public String toString () {
25
+ return "LED [ID: " + id + ", Brand: " + brand + ", Price: $" + price + "]" ;
26
+ }
27
+ }
28
+
29
+ public class LedComparison {
30
+ public static void main (String [] args ) {
31
+ Led sony = new Led (1 , "Sony" , 1500 );
32
+ Led samsung = new Led (2 , "Samsung" , 1800 );
33
+
34
+ if (sony .getPrice () > samsung .getPrice ()) {
35
+ sony .setBrand ("Premium Model" );
36
+ } else {
37
+ samsung .setBrand ("Premium Model" );
38
+ }
39
+
40
+ System .out .println (sony );
41
+ System .out .println (samsung );
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments