我尝试使用继承编写程序,根据用户使用情况打印最具成本效益的宽带/电话包。 (所以基本的想法是用户输入所需的分钟数和MB宽度,并且程序在使用方面打印最接近的匹配。) 我一直在收到错误" Constructors premium account in class premiumAccount不能应用于给定的类型"
代码如下: 子类2:
public class PremiumAccount extends IntermediateAccount {
// ------------FIELDS--------
public double dayPhone;
public double eveningPhone;
public double numberChannels;
public double broadband;
public double extraBroadband;
public double packageCost;
public double totalCost;
// -------CONSTRUCTORS
public PremiumAccount( double dPhone, double evPhone, double noChannels, double bband, double pCost, double extBroadband, double totCost){
super(dPhone, evPhone, noChannels, bband, pCost, extBroadband, totCost);
dayPhone = dPhone;
eveningPhone = evPhone;
numberChannels = noChannels;
broadband = bband;
packageCost = pCost;
extraBroadband = extBroadband;
totalCost = totCost;
};
超类:
public class BasicAccount {
// ------------FIELDS--------
protected double dayPhone;
protected double eveningPhone;
protected double numberChannels;
protected double broadband;
protected double extraBroadband;
protected double packageCost;
protected double totalCost;
// -------CONSTRUCTORS
protected BasicAccount( double dPhone, double evPhone,
double noChannels, double bband, double pCost,
double extBroadband, double totCost){
dayPhone = dPhone;
eveningPhone = evPhone;
numberChannels = noChannels;
broadband = bband;
packageCost = pCost;
extraBroadband = extBroadband;
totalCost = totCost;
};
用户类中的问题: //使用正确的值调用构造函数
newPremiumAccount = new PremiumAccount(dayphoneInput,
evenphoneInput, broadusageInput);
错误表示错误发生在 newPremiumAccount = new PremiumAccount(dayphoneInput,evenphoneInput, ^ broadusageInput);
很抱歉,如果那个代码太多了!代码还没有完成,我只是测试我将如何调用主类中的子类,但我似乎无法解决上述错误!