0
現在我正在研究責任鏈設計模式,並使用Eclipse。錯誤消息'無法解析或不是字段'
我試圖編譯這段代碼,但我的編譯錯誤「isLast會不能得到解決或不是場」:
public class OverFive implements Discount {
private Discount next; //
public boolean isLast = false;
public void setNext(Discount next, boolean Last) {
this.next = next;
this.next.isLast = Last; // Here is the error.
}
public double DoDiscount(Budget budget) {
if (budget.getValue() > 500) {
return budget.getValue() * 0.10;
}
if (this.next.isLast == false) {
return next.DoDiscount(budget);
}
else {
return 0;
}
}
}
而現在,這裏是接口:
public interface Discount {
double DoDiscount(Orcamento orcamento);
void setNext(Discount next, boolean Last);
}
是的,我知道。我用Notepad ++的替換函數做了一些修改,所以不符合標準。 – Raphael
不好.......我根本不在乎你的設計。我以爲你在使用Eclipse? – duffymo
@Raphael:那麼請再次修改它,使其*爲*標準。特別是如果你要求志願者嘗試閱讀和理解你的代碼。 1+ –