-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrade.java
More file actions
38 lines (36 loc) · 886 Bytes
/
Trade.java
File metadata and controls
38 lines (36 loc) · 886 Bytes
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
/*
* a Trade object holds 3 variables
* a Trader
* a Trade option (BUY or SALE)
* an amount
*/
public class Trade{
private Trader trader;
private TradeOption option;
private double amount;
/*
* default constructor will submit this Trade to notify all this Stock's observers
*/
public Trade(Trader trader, TradeOption option, double price) {
this.trader = trader;
this.option = option;
this.amount = price;
}
/*
* public access to Trade's details
* (Trader's name, trade option, price, Stock's name)
*/
public Trader getTrader() {
return trader;
}
public TradeOption getOptions() {
return option;
}
public double getAmount() {
return amount;
}
@Override
public String toString() {
return "The latest trade is " + trader.getName() + " " + option.name().toLowerCase() + " $" + amount;
}
}//end of class