Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 93ec82a

Browse files
committedJan 16, 2025
fourth program
1 parent dd53260 commit 93ec82a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
 

‎LedComparison.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}

0 commit comments

Comments
 (0)
Please sign in to comment.