我有这个界面:
import fondt2.extended.PhoneCall;
public interface Rate {
public double getCallCost(PhoneCall call);
public String getName();
public boolean isApplicableTo(String destinationNumber);
public boolean isValid();
}
这个抽象类有自己的构造函数:
import fondt2.extended.PhoneCall;
import java.util.Arrays;
public abstract class BandsRate implements Rate {
protected Band[] bands;
protected int intervalInMillis;
protected String name;
protected String numberRoot;
protected double startCallCost;
public BandsRate(String name,Band[] bands, int intervalInMillis, double startCallCost, String numberRoot){
this.name = name;
this.intervalInMillis = intervalInMillis;
this.startCallCost = startCallCost;
this.numberRoot = numberRoot;
this.bands = Arrays.copyOf(bands, bands.length);
}
public abstract double getCallCost(PhoneCall call);
protected double getStartCallCost(){
return this.startCallCost;
}
protected int getIntervalInMillis(){
return this.intervalInMillis;
}
现在我想创建一个扩展上面抽象类的具体类:
import java.time.Duration;
import fondt2.extended.*;
public class SimpleBandsRate extends BandsRate {
public SimpleBandsRate(String name, Band[] bands, int intervalInMillis, double startCallCost, String numberRoot){
super(name, bands, intervalInMillis, startCallCost, numberRoot);
}
double getCallCost(PhoneCall call){
double costPerInterval = getCostPerInterval(call.getStart());
if (costPerInterval == -1) {
return -1;
}
long difference = Duration.between(call.getStart(), call.getEnd()).toMillis();
int intervalCount = (int) (difference / super.getIntervalInMillis());
return (double) super.getStartCallCost() + intervalCount * costPerInterval;
}
}
编译器显示了很多错误:比如" String无法解析为变量" ,"令牌上的语法错误' numberRoot'删除此标记"," startCallCost无法解析为变量"等等。我出错了什么?