orderitem.java

来自「ssd3部分quiz、exercise、exam的参考答案」· Java 代码 · 共 34 行

JAVA
34
字号

public class OrderItem {
	
	private Product product;
	
	private int quantity;
	
	public OrderItem(Product initialProduct, int initialQuantity) {
		this.product = initialProduct;
		this.quantity = initialQuantity;
	}
	
	public void setQuantity(int newQuantity) {
		this.quantity = newQuantity;
	}
	
	public int getQuantity() {
		return this.quantity;
	}

	public Product getProduct(){
		return this.product;
	
	}
	
	public double getValue() {
		return this.getQuantity() * product.getPrice();
	}
	
	public String toString() {
		return this.getQuantity() + " " + product.getCode() + " " +
				product.getPrice();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?