item.java
来自「A system to manage a grocery store with 」· Java 代码 · 共 36 行
JAVA
36 行
package grocerystore;
public class Item implements Comparable {
private Product product;
private int pieces;
private double finalPrice;
public Item(Product product, int pieces, double price){
this.product = product;
this.pieces = pieces;
this.finalPrice = price;
}
public String getDesc() {
return product.getDesc();
}
public int getPieces() {
return pieces;
}
public double getPrice() {
return finalPrice;
}
public int compareTo(Object o) {
if (!(o instanceof Item))
throw new IllegalArgumentException();
Item item = (Item)o;
return this.product.getDesc().compareTo(item.product.getDesc());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?