public Product findProduct(Product searchProduct) 
    {
            Product found = null;
            for(Product item : stock) {
            if(item.id == searchProduct.id)
             {found=item;
             break;
             }
     }
     return found;
}

The error code reads: id has private access in Product. I am new at this and do not know how to write it correctly.

Thank you,
ladybritt

in Product class made public method

getID(){ return id;}

with proper return type, and use in place of

searchProduct.id

if(item.getID() == searchProduct.getID())

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.