Java Reference
In-Depth Information
Code 7.1
The SalesItem class
import java.util.ArrayList;
import java.util.Iterator;
/**
* The class represents sales items on an online e-commerce site (such
* as Amazon.com). SalesItem objects store all information relevant to
* this item, including description, price, customer comments, etc.
*
* NOTE: The current version is incomplete! Currently, only code
* dealing with customer comments is here.
*
* @author Michael K├Âlling and David J. Barnes
* @version 0.1 (2011-07-31)
*/
public class SalesItem
{
private String name;
private int price; // in cents
private ArrayList<Comment> comments;
/**
* Create a new sales item.
*/
public SalesItem(String name, int price)
{
this .name = name;
this .price = price;
comments = new ArrayList<Comment>();
}
/**
* Return the name of this item.
*/
public String getName()
{
return name;
}
/**
* Return the price of this item.
*/
public int getPrice()
{
return price;
}
Search WWH ::




Custom Search