Question: Exercise 4 . 5 7 Implement the findProduct method. This should look through the collection for a product whose id field matches the ID argument

Exercise 4.57 Implement the findProduct method. This should look through
the collection for a product whose id field matches the ID argument of this
method. If a matching product is found, it should be returned as the method's
result. If no matching product is found, return nu 11.
This differs from the printProductDetai1s method, in that it will not
necessarily have to examine every product in the collection before a match is
found. For instance, if the first product in the collection matches the product ID,
iteration can finish and that first Product object can be returned. On the other
hand, it is possible that there might be no match in the collection. In that case,
the whole collection will be examined without finding a product to return. In
this case, the nut1 value should be returned.
When looking for a match, you will need to call the get ID method on a Product.
 Exercise 4.57 Implement the findProduct method. This should look through the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!