我想创建一个小的库存控制程序,其中每个StockItem有5个实例变量,一个itemID,一个itemDesc,一个价格,一个数量和一个reOrderLevel。我已经在StockItem文件中设置了我的构造函数,并且在尝试创建测试程序文件以测试我的所有方法时遇到了问题。当我尝试使用我的构造函数创建一个新的StockItem,我得到的错误:调用构造函数时数据类型不正确
要求:字符串,字符串,双,INT,INT 发现:字符串,字符串,字符串,字符串,字符串
如何我可以修复这个错误吗?我不确定它是否是我的构造函数中的错误,或者如果我的测试器文件中的代码是错误的。
在此先感谢。
这里是我的构造函数代码:
public class StockItem {
String itemID;
String itemDesc;
Double price;
int quantity;
int reOrderLevel;
//declaring my instance variables
public StockItem (String itemID, String itemDesc, Double price, int quantity, int reOrderLevel) {
this.itemID = itemID;
this.itemDesc = itemDesc;
this.price = price;
this.quantity = quantity;
this.reOrderLevel = reOrderLevel;
}
,这里是我的测试代码,到目前为止,试图创建一个项目:
public class StockItemTester {
public static void main (String[] args) {
StockItem item1 = new StockItem ("ABC", "iPhone 5", " 500", "3", "10");
}
}
你知道一个方法/构造函数_signature_是什么吗? – Juvanis 2013-04-04 13:28:32
在这种情况下,错误消息本身会为您提供大量信息。 – midhunhk 2013-04-04 13:30:39
在附注上,你真的想要一个'Double'对象而不是'double'原始类型吗? – Quetzalcoatl 2013-04-04 13:39:53