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 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
This differs from the printProductDetais 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 nut value should be returned.
When looking for a match, you will need to call the get ID method on a Product.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
