-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoods.java
More file actions
71 lines (49 loc) · 1.1 KB
/
Copy pathGoods.java
File metadata and controls
71 lines (49 loc) · 1.1 KB
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
package chapter02;
public class Goods {
private String name;
private int price;
private int countStock;
private int countSold;
public static Goods getInstance() {
return new Goods();
}
public static int countOfGoods;
public Goods() {
countOfGoods ++;
}
public void showInfo() {
System.out.println(name);
System.out.println(price);
System.out.println(countStock);
System.out.println(countSold);
}
public int calcDisCountPrice(float discountRate) {
return price - (int)(price * discountRate);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
if(price != -1) {
this.price = price;
}
}
public int getCountStock() {
return countStock;
}
public void setCountStock(int countStock) {
this.countStock = countStock;
}
public int getCountSold() {
return countSold;
}
public void setCountSold(int countSold) {
this.countSold = countSold;
}
}