Expected time required: 15 min
In this scenario, you are completing an application that processes users of an online store. New terms and conditions
have been released and you need to check a List
of customers to make sure they have accepted these new terms. Write a
lambda expression that implements the Consumer
functional interface that consumes an user from a List
, and calls
a method to email that user if they have not accepted the new terms. The resource DatabaseManager
will handle some
functionality including emailing the specific customers. The method checkCustomers
in the class CustomerManager
has
some TODO methods for you to complete.
CustomerManager
has a methodcheckCustomers
that has TODO comments. Using theforEach
method ofList
, use a lambda expression that consumes the items contained in theList
. You'll pass the lambda expression as the input argument to theforEach
method. Implement the lambda expression in-line.DatabaseManager
has a methodcheckCustomer(String name)
that accepts aString
that is the name of a customer. UseStrings
from the customersList
to send to this method. The method will returntrue
if the customer has already accepted the terms and conditions and will returnfalse
if they have not accepted the terms and conditions.- If
checkCustomer()
returnsfalse
, then you must call theDatabaseManager
methodemailCustomer(String name)
. Call the methodemailCustomer(String name)
with the customer name and the resource will handle the rest.
HINTS: