📄 item.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -