merge branch develop to main #1

Merged
Meraj merged 6 commits from develop into main 2026-05-18 23:33:27 +00:00
Showing only changes of commit 0410d312b1 - Show all commits
+16 -1
View File
@@ -103,11 +103,26 @@ public class MovieService {
* PUT ALL PARSING CODE INSIDE try-catch
*/
public void displayMoviesByGenre(Long genreId, Long page) {
// TODO: Write your code here
// All parsing code must be inside try-catch
try {
// Your code here
String jsonResponse = getMoviesByGenreList(genreId, page);
JsonObject jsonObject = JsonParser.parseString(jsonResponse).getAsJsonObject();
JsonArray jsonMovies = jsonObject.getAsJsonArray("movies");
System.out.println("\nMovies for genre " + genreId + " (Page " + page + "):");
for (JsonElement element: jsonMovies) {
JsonObject movie = element.getAsJsonObject();
long id = movie.get("id").getAsLong();
String title = movie.get("title").getAsString();
String year = movie.get("year").getAsString();
System.out.println("ID: " + id + " | " + title + " (" + year + ")");
}
long total = jsonObject.get("total").getAsLong();
long totalPages = jsonObject.get("total_pages").getAsLong();
System.out.println("Total: " + total +"\n" + "Total pages: " + totalPages);
// Your code here
} catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
}