-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStock.java
More file actions
97 lines (76 loc) · 2.18 KB
/
Copy pathStock.java
File metadata and controls
97 lines (76 loc) · 2.18 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Class that represents a stock
public class Stock implements BankComponent, Exchangeable, Tradeable {
private final ID id = new ID();
private String name;
private String ticker;
private Currency currentPrice;
private Currency openPrice;
private Currency highPrice;
private Currency lowPrice;
private Currency closePrice;
private int volume;
public Stock(String name, String ticker, Currency currentPrice, int volume) {
this.name = name;
this.ticker = ticker;
this.currentPrice = currentPrice;
this.volume = volume;
}
public ID getID() {
return id;
}
// method to exchange a stock to a different currency that exchanges all of its prices
public void exchangeTo(String currencyType) {
openPrice.convertTo(currencyType);
highPrice.convertTo(currencyType);
lowPrice.convertTo(currencyType);
closePrice.convertTo(currencyType);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTicker() {
return ticker;
}
public void setTicker(String ticker) {
this.ticker = ticker;
}
public Currency getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(Currency currentPrice) {
this.currentPrice = currentPrice;
}
public Currency getOpenPrice() {
return openPrice;
}
public void setOpenPrice(Currency openPrice) {
this.openPrice = openPrice;
}
public Currency getHighPrice() {
return highPrice;
}
public void setHighPrice(Currency highPrice) {
this.highPrice = highPrice;
}
public Currency getLowPrice() {
return lowPrice;
}
public void setLowPrice(Currency lowPrice) {
this.lowPrice = lowPrice;
}
public Currency getClosePrice() {
return closePrice;
}
public void setClosePrice(Currency closePrice) {
this.closePrice = closePrice;
}
public int getVolume() {
return volume;
}
public void setVolume(int volume) {
this.volume = volume;
}
}