-2
我被困在一个练习中,这真的让我难以忍受。基本上在这个代码中,我希望这个传递方法的结果调用increaseQuantity
方法,虽然我相信它很简单,但编译时我经常遇到一个错误。增加数量错误 - 解决方案?
错误消息读取:类产品
方法increaseQuantity不能给予给定的类型;需要int;发现:没有参数;理由:实际和正式参数列表的长度不同。
我已经从字面上撞上了这面墙,所以任何帮助将不胜感激十倍!
public int delivery (int id, int amount)
{
int index = 0;
boolean searching = true;
Product myproduct = stock.get(0);
while(searching && index < myproduct.getID()){
int Products = myproduct.getID();
if(Products == id) {
searching = false;
}
else {
index++;
}
}
if(searching) {
return 0;
}
else {
return myproduct.increaseQuantity();
}
}
非常感谢那些回应。
好吧,你需要添加一个'int'参数,如错误 – AxelH
看起来你'increaseQuantity()'方法需要一个'int'作为参数,但你给它什么都不说。此外,如果您在编程时“实际上”撞墙,您需要与工作场所的健康和安全代表联系。 – jsheeran
也许你可以分享你的产品类代码,或者至少增加incrementQuantity()方法的源代码 – alainlompo