Here is a basic class I have set up to calculate earnings with stocks. Focus on the "Stock" constructor here:
public class Stock{
private String symbol;
private int totalShares;
private double totalCost;
public void Stock(String symbol){
this.symbol = symbol;
totalShares = 0;
totalCost = 0.0;
}
public double getProfit(double currentPrice){
double marketValue = totalShares * currentPrice;
return marketValue - totalCost;
}
public void purchase(int shares, double pricePerShare){
totalShares += shares;
totalCost += shares*pricePerShare;
}
public int getTotalShares(){
return totalShares;
}
}
I have created a subclass called DividendStock, which is supposed to calculate dividend earnings.
public class DividendStock extends Stock{
private double dividends;
public DividendStock(String symbol){
super(symbol);
dividends = 0.0;
}
public void payDividend(double amountPerShare){
dividends += amountPerShare*getTotalShares();
}
}
The constructor of this class doesnt allow me to call the superclass's constuctor: super(symbol); The error message is as goes: "constructor Stock in class Stock cannot be applied to given types;"
I have searched for a solution, but everything seems to be in place. Any ideas of why it doesnt allow me to call this constructor?