으로 변환 할 수 없습니다. java 클래스 어댑터가 있습니다.이 객체는 Groceries.java로 변환 할 수 없으므로 오류가 발생합니다 (Groceries b : getData()). B : GetData의은()) 나 메소드 b.getProduct()를 호출 할 수 getSn()를 Groceries.java에서오류 : 호환되지 않는 유형의 객체를 (Java 클래스)
DataAdapter.java
public Groceries getBelBySN(String sn) {
Groceries pp = null;
for (Groceries b : getData()) {
if (b.getProduct().getSn().equals(sn)) {
pp = b;
break;
}
}
return pp;
}
public void updateTotal() {
long jumlah = 0;
for (Groceries b : getData()) {
jumlah = jumlah + (b.getProduct().getHarga() * b.getQuantity());
}
total = jumlah;
}
를이 난 어댑터 부르는 Groceries.java이다.
public class Groceries {
protected Product product;
protected int quantity;
public Groceries(Product product, int quantity) {
this.product = product;
this.quantity = quantity;
}
public void setProduct(Product product) {
this.product = product;
}
public Product getProduct() {
return product;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getQuantity() {
return quantity;
}
'getData()'는 무엇을 반환합니까? 우리에게'getData()'의 코드를 보여줄 수 있습니까? –
getData()는 목록에서입니다 – Rizal