Skip to content

Commit a10153e

Browse files
authored
Create Product.java
1 parent 735fa89 commit a10153e

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.zetcode;
2+
3+
import java.math.BigDecimal;
4+
5+
public class Product {
6+
7+
private String name;
8+
private String category;
9+
private BigDecimal price;
10+
11+
public Product(String name, String category, BigDecimal price) {
12+
this.name = name;
13+
this.category = category;
14+
this.price = price;
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public String getCategory() {
26+
return category;
27+
}
28+
29+
public void setCategory(String category) {
30+
this.category = category;
31+
}
32+
33+
public BigDecimal getPrice() {
34+
return price;
35+
}
36+
37+
public void setPrice(BigDecimal price) {
38+
this.price = price;
39+
}
40+
41+
@Override
42+
public String toString() {
43+
44+
var sb = new StringBuilder("Product{");
45+
sb.append("name='").append(name).append('\'');
46+
sb.append(", category='").append(category).append('\'');
47+
sb.append(", price=").append(price);
48+
sb.append('}');
49+
return sb.toString();
50+
}
51+
}

0 commit comments

Comments
 (0)