-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCall.java
More file actions
30 lines (27 loc) · 809 Bytes
/
Call.java
File metadata and controls
30 lines (27 loc) · 809 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
public class Call implements Holding {
private double strikePrice;
private double premium;
private boolean Buy;
// constructor is INTERNAL — not called directly by users
public Call(double strikePrice, double premium, boolean Buy) {
this.strikePrice = strikePrice;
this.premium = premium;
this.Buy = Buy;
}
public double end(double stockPrice) {
if (stockPrice > strikePrice) {
double valuereturn = (stockPrice - strikePrice) * 100 - premium;
if (Buy) {
return valuereturn;
} else {
return -valuereturn;
}
} else {
if (Buy) {
return -premium;
} else {
return premium;
}
}
}
}