From 40fb9e3eadbbe2705886cb3d2e03dab77cc0a8b2 Mon Sep 17 00:00:00 2001 From: zhangsiyuan <3837703520@qq.com> Date: Sun, 29 Mar 2026 19:52:53 +0800 Subject: [PATCH] =?UTF-8?q?w4-=E5=BC=A0=E6=80=9D=E6=B8=8A-202401070104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/project/display/ResultDisplay.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 project/src/project/display/ResultDisplay.java 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