⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise 3.orderitem.java

📁 son los ejercicios de ssd3 espero que les ayuden a algunos jeje se la pasan chido.....!!!!!!
💻 JAVA
字号:
/**
 * This class models an item in an order.
 * 
 * @author Neil
 * @version 1.0.0
 * @see Product
 */
public class OrderItem {

	private Product product;
	private int quantity;

	/**
	 * Constructor that initializes the instance variables product and quantity.
	 * 
	 * @param initialProduct
	 * @param initialQuantity
	 */
	public OrderItem(Product initialProduct, int initialQuantity) {
		product = initialProduct;
		quantity = initialQuantity;
	}

	/**
	 * Getter of the property <tt>product</tt>
	 * 
	 * @return Returns the product.
	 * 
	 */
	public Product getProduct() {
		return product;
	}

	/**
	 * Getter of the property <tt>quantity</tt>
	 * 
	 * @return Returns the quantity.
	 * 
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * Setter of the property <tt>quantity</tt>
	 * 
	 * @param quantity
	 *            The quantity to set.
	 * 
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	/**
	 * Returns the product of quantity and price.
	 * 
	 * @return Returns the product of quantity and price.
	 */
	public double getValue() {
		return product.getPrice() * quantity;
	}

	/**
	 * Overrides the method toString in the class Object.
	 * 
	 * @return Returns the string representation of an OrderItem object. The
	 *         String representation has the following format:
	 *         <tt>quantity product-code product-price</tt>
	 */
	public String toString() {
		return quantity + " " + product.getCode() + " " + product.getPrice();
	}
}

⌨️ 快捷键说明

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