我正在編寫一個程序,它調用來自同一文件夾中不同類的「發票」方法。我不斷收到以下錯誤:Java - 錯誤:找不到符號
error: cannot find symbol
strInvoice = invoice();
^
symbol: method invoice()
這裏是我如何在我的程序的方法調用:
strInvoice= invoice();
JOptionPane.showInputDialog(null, strInvoice, "*Name*'s Party Store", -1);
這是該方法看起來像在位於類文件相同的文件夾:
public String invoice()
{
String strInfo=""; //string returned containing all the information
double dBalloonNoDiscount; //balloon total without discount
double dCandleNoDiscount; //candle total without discount
double dBannerNoDiscount; //banner total without discount
double dSubtotal; //subtotal
double dTax; //tax
double dShippingCost; //shipping cost
double dTotal; //total
String strShippingType; //shipping type
dBalloonNoDiscount = balloons * 2.50;
dCandleNoDiscount = candles * 6.00;
dBannerNoDiscount = banners * 2.00;
dSubtotal = subtotal();
dTax = tax();
dShippingCost = shippingCost();
strShippingType = shippingType();
dTotal = orderTotal();
strInfo += "\nQuantity"
+ "\n\nBalloons: " + balloons + " @ $2.50 = "
+ df.format(dBalloonNoDiscount) + "* Discount Rate: "
+ df.format(discount('B')) + " = "
+ df.format(subtotal('B'))
+ "\n\nCandles: " + candles + " @ 6.00 = "
+ df.format(dCandleNoDiscount) + "* Discount Rate: "
+ df.format(discount('C')) + " = "
+ df.format(subtotal('C'))
+ "\n\nBanners: " + banners + " @ $2.50 = "
+ df.format(dBannerNoDiscount) + "* Discount Rate: "
+ df.format(discount('N')) + " = "
+ df.format(subtotal('N'))
+ "\nSubtotal: " + df.format(dSubtotal)
+ "\n Tax: " + df.format(dTax)
+ "\nShipping: " + df.format(dShippingCost) + " - "
+ strShippingType
+ "\n Total: " + dTotal;
return strInfo;
}
我希望這是足夠的信息。我似乎無法找到問題。
我建議你回顧一些OO和Java的基礎知識,嘗試做幾個簡單的例子並嘗試這個。從長遠來看,這肯定會有所幫助。 – Krishna