|
| 1 | +package exercise8 |
| 2 | + |
| 3 | +import java.time.LocalDate |
| 4 | + |
| 5 | +/** |
| 6 | + * Represents a movie director. |
| 7 | + * |
| 8 | + * @property name The name of the movie director. |
| 9 | + */ |
| 10 | +data class MovieDirector(val name: String) |
| 11 | + |
| 12 | +/** |
| 13 | + * Represents a movie actor. |
| 14 | + * |
| 15 | + * @property name The name of the actor. |
| 16 | + */ |
| 17 | +data class MovieActor(val name: String) |
| 18 | + |
| 19 | +/** |
| 20 | + * Represents a Movie. |
| 21 | + * |
| 22 | + * @property title The title of the movie. |
| 23 | + * @property budget The budget of the movie in dollars. |
| 24 | + * @property revenue The revenue of the movie in dollars. |
| 25 | + * @property releaseDate The release date of the movie. |
| 26 | + * @property runtimeInMinutes The runtime of the movie in minutes. |
| 27 | + * @property director The director of the movie. |
| 28 | + * @property genres The genres of the movie. |
| 29 | + * @property actors The actors in the movie. |
| 30 | + * @property rating The rating of the movie. |
| 31 | + */ |
| 32 | +data class Movie( |
| 33 | + val title: String, |
| 34 | + val budget: Long, |
| 35 | + val revenue: Long, |
| 36 | + val releaseDate: LocalDate, |
| 37 | + val runtimeInMinutes: Int, |
| 38 | + val director: MovieDirector, |
| 39 | + val genres: List<String>, |
| 40 | + val actors: List<MovieActor>, |
| 41 | + val rating: Double |
| 42 | +) |
| 43 | + |
| 44 | +interface MovieDBApi { |
| 45 | + /** |
| 46 | + * |
| 47 | + * Retrieves a list of all movies that feature the given actor. |
| 48 | + * |
| 49 | + * @param actor The actor to search for. |
| 50 | + * @return A list of movies that feature the given actor. |
| 51 | + */ |
| 52 | + fun getAllMoviesByActor(actor: MovieActor): List<Movie> |
| 53 | + |
| 54 | + /** |
| 55 | + * Retrieves a list of movies with the best profits. |
| 56 | + * |
| 57 | + * Movie profits are calculated by deducting revenue from its budget. |
| 58 | + * |
| 59 | + * @param numOfMovies The number of movies to retrieve. |
| 60 | + * @return A list of movies with the best earnings. |
| 61 | + */ |
| 62 | + fun getMoviesWithBiggestProfit(numOfMovies: Int): List<Movie> |
| 63 | + |
| 64 | + /** |
| 65 | + * Retrieves the best-rated movie featuring the given actor. |
| 66 | + * |
| 67 | + * @param actor The actor to search for. |
| 68 | + * @return The best-rated movie featuring the given actor, or null if no movie is found. |
| 69 | + */ |
| 70 | + fun getBestRatedMovieByActor(actor: MovieActor): Movie? |
| 71 | + |
| 72 | + /** |
| 73 | + * Retrieves a list of all movies released in the specified year. |
| 74 | + * |
| 75 | + * @param year The year of release. |
| 76 | + * @return A list of movies released in the specified year. |
| 77 | + */ |
| 78 | + fun getAllMoviesByYear(year: Int): List<Movie> |
| 79 | + |
| 80 | + /** |
| 81 | + * Retrieves a list of all movies that belong to the given genre. |
| 82 | + * |
| 83 | + * @param genre The genre to search for. |
| 84 | + * @return A list of movies that belong to the given genre. |
| 85 | + */ |
| 86 | + fun getAllMoviesByGenre(genre: String): List<Movie> |
| 87 | + |
| 88 | + /** |
| 89 | + * Retrieves a list of the best-rated movies. |
| 90 | + * |
| 91 | + * The best-rated movies are determined by their rating, with the highest-rated movies appearing first. |
| 92 | + * |
| 93 | + * @param numOfMovies The number of movies to retrieve. |
| 94 | + * @return A list of the best-rated movies. |
| 95 | + */ |
| 96 | + fun getBestRatedMovies(numOfMovies: Int): List<Movie> |
| 97 | + |
| 98 | + /** |
| 99 | + * Retrieves the movie director who has directed the most movies. |
| 100 | + * |
| 101 | + * @return The movie director with the most movies directed. |
| 102 | + */ |
| 103 | + fun getDirectorWithMostMoviesDirected(): MovieDirector |
| 104 | + |
| 105 | + /** |
| 106 | + * Retrieves a list of actor pairs who have the most movies they acted in together. |
| 107 | + * |
| 108 | + * @return A list of MovieActor objects representing the actors with the most costarred movies. |
| 109 | + */ |
| 110 | + fun getActorsWithMostCostarredMovies(): List<Pair<MovieActor, MovieActor>> |
| 111 | +} |
| 112 | + |
0 commit comments