Browse Source

w4-张思渊-202401070104

main
zhangsiyuan 3 weeks ago
parent
commit
40fb9e3ead
  1. 47
      project/src/project/display/ResultDisplay.java

47
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<Movie> 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<Double, Long> 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<Integer, Double> 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<String, Long> 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<Movie> 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<Movie> 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");
}
}
Loading…
Cancel
Save