All pastes #208466 Raw Edit

ItemVO.java

public java v1 · immutable
#208466 ·published 2006-10-18 17:07 UTC
rendered paste body
// ItemInfo.javapackage model;import server.*;public class ItemVO implements java.io.Serializable{        private String itemID;    private String description;    private int quantity;    private double price;        public ItemVO(String itemID,String description, int quantity, double price) throws ShoppingException    {        setID(itemID);        setDescription(description);        setQuantity(quantity);        setPrice(price);    }        public String getID()    {         return itemID;     }        public String getDescription()    {        return description;     }        public int getQuantity()    {         return quantity;     }        public double getPrice()    {         return price;     }        public void setID(String itemID) throws ShoppingException    {        if ((itemID == null) || itemID.equals(""))            throw new ShoppingException("Invalid ID");        this.itemID = itemID;    }        public void setDescription(String description) throws ShoppingException    {        if ((description == null) || description.equals(""))            throw new ShoppingException("Invalid description");        this.description = description;    }        public void setQuantity(int quantity) throws ShoppingException    {        if (quantity < 0) throw                new ShoppingException("Quantity cannot be less than 0");        this.quantity = quantity;    }        public void setPrice(double price) throws ShoppingException    {        if (price < 0) throw                new ShoppingException("Price cannot be less than 0");        this.price = price;    }        public void changeQuantity(int delta) throws ShoppingException    {        quantity += delta;        if (quantity < 0) throw                new ShoppingException("Quantity cannot be less than 0");    }            public int hashCode()    {        return itemID.hashCode();    }        public boolean equals(Object object)    {        boolean identical = false;        if (object instanceof ItemVO)        {            ItemVO other = (ItemVO)object;            if (itemID.equalsIgnoreCase(other.itemID))                identical = true;        }        return identical;    }        public String toString()    {        return itemID + ":" + description + ":" + quantity + ":" + price;    }}