diff --git a/project/src/project/display/ResultDisplay.java b/project/src/project/display/ResultDisplay.java new file mode 100644 index 0000000..c766f81 --- /dev/null +++ b/project/src/project/display/ResultDisplay.java @@ -0,0 +1,47 @@ +package project.display; + +import project.bean.Movie; +import project.analysis.MovieAnalyzer; + +import java.util.List; +import java.util.Map; + +public class ResultDisplay { + public static void displayResults(List movies) { + System.out.println("===== Movie Data Analysis Results ====="); + System.out.println("Total movies: " + movies.size()); + System.out.printf("Average rating: %.2f\n\n", MovieAnalyzer.getAverageRating(movies)); + + System.out.println("===== Rating Distribution ====="); + Map ratingDistribution = MovieAnalyzer.getRatingDistribution(movies); + ratingDistribution.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(entry -> System.out.printf("Rating %.1f: %d movies\n", entry.getKey(), entry.getValue())); + + System.out.println("\n===== Year-Rating Correlation ====="); + Map yearRating = MovieAnalyzer.getYearRatingCorrelation(movies); + yearRating.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(entry -> System.out.printf("%d: %.2f\n", entry.getKey(), entry.getValue())); + + System.out.println("\n===== Director Movie Count Ranking ====="); + Map directorCount = MovieAnalyzer.getDirectorMovieCount(movies); + directorCount.entrySet().stream() + .limit(10) + .forEach(entry -> System.out.printf("%s: %d movies\n", entry.getKey(), entry.getValue())); + + System.out.println("\n===== Top 10 Highest Rated Movies ====="); + List topRated = MovieAnalyzer.getTopRatedMovies(movies, 10); + for (int i = 0; i < topRated.size(); i++) { + Movie movie = topRated.get(i); + System.out.printf("%d. %s (%.1f) - %d - Director: %s\n", + i + 1, movie.getTitle(), movie.getRating(), movie.getYear(), movie.getDirector()); + } + } + + public static void generateCharts(List movies) throws Exception { + System.out.println("\n===== Chart Generation ====="); + System.out.println("Due to environment limitations, chart generation is not implemented"); + System.out.println("Suggest using JFreeChart or other chart libraries for visualization"); + } +} \ No newline at end of file