/Users/lyon/j4p/src/xml/Product.java

1    package xml; 
2     
3    public class Product { 
4        private String name; 
5        private float price; 
6        private int productCode; 
7     
8        public Product(String _name, 
9                       float _price, 
10                      int _productCode) { 
11           name = _name; 
12           price = _price; 
13           productCode = _productCode; 
14       } 
15    
16       public String toString() { 
17           return "name:" + name 
18                   + "\tprice:$" + price 
19                   + "\tproductCode:" + productCode; 
20       } 
21    
22       public float getPrice() { 
23           return price; 
24       } 
25    
26       public String getName() { 
27           return name; 
28       } 
29    
30       public int getProductCode() { 
31           return productCode; 
32       } 
33    
34       public boolean equals(Product p) { 
35           return 
36                   p.getProductCode() == productCode; 
37       } 
38    
39   }