[Bluej-discuss] Ex.4.38

Mike Stevens howlinhuskie1 at shaw.ca
Fri Nov 10 07:35:54 GMT 2006


Hi I was wondering if I'm headed in the right direction with this exercise.

 

public void addProduct(Product item)
    {
 
        //Using a local var to store new Item
        ArrayList <Product>stockString = new ArrayList<Product>();
        stockString.add(item);
        
        Iterator it = stock.iterator();
            while(it.hasNext()) {
                Product inStock = (Product) it.next();
 
                //This is the problem.
                //The compiler is not letting me use the getID() method - 
                //for the local var stockString
                if(inStock.getID() != stockString.getID())
                {
                    stock.add(item);
                }else{
                    System.out.print("Id used");
                }
            }
    }

 

If anybody can point me in the right direction for comparing the new Object
id and exciting Object id's that would be great

 

Thanks

Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20061110/de9c8169/attachment.html


More information about the bluej-discuss mailing list