📄 cartitem.java
字号:
/*
* @author : Neelesh
* @Version : 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the File : CartItem.java
* Creation/Modification History :
*
* Neelesh 07-Feb-2002 Created
*
*/
package oracle.otnsamples.vsm.services.data;
/**
* Represents an Item in the cart. This class has a set of getter and setter
* methods to manage the item details and the quantity information.
*
* @author Neelesh
* @version 1.0
*/
public class CartItem implements java.io.Serializable {
private String id; // Item Id
private String itemName; // Details of the item
private String shopId; // Shop Id
private double unitPrice;
private int quantity; // Number of quantity ordered
/**
* Default Constructor, takes no arguments
*/
public CartItem() {
}
/**
* The constructor creates a cart item with the specified values
*
* @param <b>details</b> details
* @param <b>Id</b> Id
* @param <b>quantity</b> quantity
*/
public CartItem(String id, int quantity, String name, double unitPrice) {
this.itemName = name;
this.id = id;
this.quantity = quantity;
this.unitPrice = unitPrice;
}
/**
* Gets the Item quantity
*
* @return <b>quantity</b> number of quantity
*/
public int getQuantity() {
return quantity;
}
/**
* Calculates the total value
*
* @return <b>double</b> total amount
*/
public double getAmount() {
// Round the amount to 2 -decimals
return Math.round(unitPrice * quantity * 100) / 100.0;
}
/**
* Gets the unit price for this item
*
* @return <b>double</b> unit price
*/
public double getUnitPrice() {
return unitPrice;
}
/**
* Gets the Item details
*
* @return <b>ItemDetails</b> Object contain item details
*/
public String getItemName() {
return itemName;
}
/**
* Gets the Item id
*
* @return <b>ID</b> item id
*/
public String getId() {
return id;
}
/**
* Gets the shop id
*
* @return <b>shopId</b> shop id
*/
public String getShopId() {
return shopId;
}
/**
* Sets the number of quantity
*
* @param <b>quantity</b> number of quantity
*/
public void setQuantity(int quantity) {
this.quantity = quantity;
}
/**
* Sets the item name
*
* @param <b>name</b> Item name
*/
public void setItemName(String name) {
itemName = name;
}
/**
* Sets the item id
*
* @param <b>Id</b> item id
*/
public void setId(String ID) {
this.id = ID;
}
/**
* Sets the shop id
*
* @param <b>shopId</b> shop id
*/
public void setShopId(String shopId) {
this.shopId = shopId;
}
/**
* Sets the unit price for this item
*
* @param <b>unitPrice</b> unit price
*/
public void setUnitPrice(double unitPrice) {
this.unitPrice = unitPrice;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -