-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLedComparison.java
43 lines (35 loc) · 959 Bytes
/
LedComparison.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
class Led {
private int id;
private String brand;
private double price;
public Led(int id, String brand, double price) {
this.id = id;
this.brand = brand;
this.price = price;
}
public double getPrice() {
return price;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String toString() {
return "LED [ID: " + id + ", Brand: " + brand + ", Price: $" + price + "]";
}
}
public class LedComparison {
public static void main(String[] args) {
Led sony = new Led(1, "Sony", 1500);
Led samsung = new Led(2, "Samsung", 1800);
if (sony.getPrice() > samsung.getPrice()) {
sony.setBrand("Premium Model");
} else {
samsung.setBrand("Premium Model");
}
System.out.println(sony);
System.out.println(samsung);
}
}