Exercise: Add a Recommended Movie

Refactor a method to use LINQ.

We'll cover the following

Accepting movie recommendations

Now, it’s your turn to refactor a method to accept movie recommendations.

This time, we have a list of movies to watch. We have decided to create some rules to accept them based on their director’s name, release year, and reviews.

These are our rules to accept a recommendation:

  • If a movie is from one of our favorite directors, accept it.
  • If it’s from the '60s or '70s, accept it.
  • If it’s from our favorite sagas, definitively accept it.
  • If it’s a horror film from John Carpenter, definitively accept it.
  • If it has at least one bad review, we should not accept it.

We have an if statement inside the AcceptMovieRecommendation method for each rule.

By the way, there are some mistakes for you to catch below. Let’s also remember how to fix some of the common mistakes we made when using LINQ.

Get hands-on with 1200+ tech skills courses.