You are the manager of a fancy restaurant that has a sizable wine cellar. A lot of your customers are demanding wine enthusiasts. Finding the right bottle of wine for a particular customer is not an easy task.
As a tech-savvy restaurant owner, you decided to speed up the wine selection process by writing an app that will let guests filter your wines by their preferences.
A bottle of wine is represented using a custom type, and wines are stored in a list.
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
]Implement the wines_of_color function. It should take a list of wines and return all wines of a given color.
wines_of_color(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
color: White
)
// -> [
// Wine("Chardonnay", 2015, "Italy", White),
// Wine("Pinot grigio", 2017, "Germany", White),
// ]Implement the wines_from_country function. It should take a list of wines and return all wines from a given country.
wines_from_country(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
country: "Germany"
)
// -> [
// Wine("Dornfelder", 2018, "Germany", Rose)
// ]Implement the filter function. It should take a list of wines, a color and a country and return all wines of the given color bottled in the given country.
filter(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
color: White
country: "Italy"
)
// -> [
// Wine("Chardonnay", 2015, "Italy", White),
// ]You are the manager of a fancy restaurant that has a sizable wine cellar. A lot of your customers are demanding wine enthusiasts. Finding the right bottle of wine for a particular customer is not an easy task.
As a tech-savvy restaurant owner, you decided to speed up the wine selection process by writing an app that will let guests filter your wines by their preferences.
A bottle of wine is represented using a custom type, and wines are stored in a list.
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
]Implement the wines_of_color function. It should take a list of wines and return all wines of a given color.
wines_of_color(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
color: White
)
// -> [
// Wine("Chardonnay", 2015, "Italy", White),
// Wine("Pinot grigio", 2017, "Germany", White),
// ]Implement the wines_from_country function. It should take a list of wines and return all wines from a given country.
wines_from_country(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
country: "Germany"
)
// -> [
// Wine("Dornfelder", 2018, "Germany", Rose)
// ]Implement the filter function. It should take a list of wines, a color and a country and return all wines of the given color bottled in the given country.
filter(
[
Wine("Chardonnay", 2015, "Italy", White),
Wine("Pinot grigio", 2017, "Germany", White),
Wine("Pinot noir", 2016, "France", Red),
Wine("Dornfelder", 2018, "Germany", Rose)
],
color: White
country: "Italy"
)
// -> [
// Wine("Chardonnay", 2015, "Italy", White),
// ]