From 5704749daeaa3791927eafded86d26302231bbb8 Mon Sep 17 00:00:00 2001 From: Sadeghizad Date: Thu, 23 Apr 2026 09:46:06 +0330 Subject: [PATCH 01/10] (feat): add method for get movie info --- src/main/java/movie/apis/MovieService.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/movie/apis/MovieService.java b/src/main/java/movie/apis/MovieService.java index 0f5015c..da23371 100644 --- a/src/main/java/movie/apis/MovieService.java +++ b/src/main/java/movie/apis/MovieService.java @@ -11,7 +11,7 @@ public class MovieService { private final static String GENRES_URL = "https://moviesapi.ir/api/v1/genres"; private static String MOVIES_BY_GENRE_URL = "https://moviesapi.ir/api/v1/genres/"; - private final static String MOVIE_INFO = "https://moviesapi.ir/api/v1/movies/{movie_id}";//todo fazel + private final static String MOVIE_INFO = "https://moviesapi.ir/api/v1/movies/{movie_id}"; private final static HttpClient client = HttpClient.newHttpClient(); private ArrayList moviesList; private ArrayList genresList; @@ -61,6 +61,31 @@ public class MovieService { return null; } + private String getMovieInfo(Long movieId) { + try { + + String url = MOVIE_INFO.replace("{movie_id}", movieId.toString()); + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .build(); + + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + + if (response.statusCode() == 200) { + System.out.println("Movie Info received successfully"); + return response.body(); + } else { + throw new IOException("HTTP error code: " + response.statusCode()); + } + + } catch (Exception e) { + System.out.println("!!Exception : " + e.getMessage()); + } + + return null; + } + // TODO: Write a method that parses the JSON returned by getGenresList() into a list of Genre objects. // TODO: Write a method that displays the list of genres. From 0bd31c6f76ecf5587fe76cc3cd0057275fe1a144 Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 08:49:20 +0000 Subject: [PATCH 02/10] Update src/main/java/Rational/Rational.java --- src/main/java/Rational/Rational.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/Rational/Rational.java b/src/main/java/Rational/Rational.java index 7fa04fa..7bd840e 100644 --- a/src/main/java/Rational/Rational.java +++ b/src/main/java/Rational/Rational.java @@ -39,14 +39,14 @@ public class Rational { } } - // ✅ COMPLETED - Instance method: this + other + // COMPLETED - Instance method: this + other public Rational add(Rational other) { int newNumerator = this.numerator * other.denominator + other.numerator * this.denominator; int newDenominator = this.denominator * other.denominator; return new Rational(newNumerator, newDenominator); } - // ✅ COMPLETED - Static method: r1 + r2 + // COMPLETED - Static method: r1 + r2 public static Rational add(Rational r1, Rational r2) { return r1.add(r2); } @@ -92,7 +92,7 @@ public class Rational { return null; // Remove this line when implemented } - // ✅ PROVIDED - String representation + // PROVIDED - String representation @Override public String toString() { if (denominator == 1) { @@ -101,7 +101,7 @@ public class Rational { return numerator + "/" + denominator; } - // ✅ PROVIDED - Decimal value + // PROVIDED - Decimal value public double toDouble() { return (double) numerator / denominator; } From 821190d9bdc932740d2e87633c4dfbd536d0c72c Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 09:13:46 +0000 Subject: [PATCH 03/10] Update README.md --- README.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/README.md b/README.md index 139597f..5f0ccbf 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,106 @@ +## Third Assignment: Movie Explorer 🎬 + Rational Calculator 🧮 +--- +Welcome to Your Third Assignment in the Advanced Programming Course! +This assignment consists of two separate parts. You must complete both parts. +--- + +## Part 1: Rational Class (Rational Numbers) +In this part, you will implement a Rational class that supports basic mathematical operations. + +Tasks: +Define fields for numerator and denominator + +Implement a constructor and a reduce() method for simplification + +Implement addition, subtraction, multiplication, and division as instance methods + +Implement addition, subtraction, multiplication, and division as static methods + +# Note: Detailed TODO comments are provided inside Rational.java. +--- +## Part 2: Movie Explorer 🎬 (Using API) +In this part, you will develop a Java application that fetches movie data from an API and allows users to browse and search movies. + +Files Provided: +Movie.java + +Genre.java + +MovieService.java + +Main.java + +Tasks: +Complete the Movie class (fields, constructor, getters/setters) + +Complete the Genre class (fields, constructor, getters/setters) + +Parse JSON data from getGenresList() into a list of Genre objects + +Display the list of genres to the user + +Fetch and return a list of movies by genreId and page number + +Display the genres of a specific movie + +Implement a console menu in Main to receive user input and display data + +# Note: Detailed TODO comments are provided inside each of the above source files. +--- +## Objectives ✏️ +By completing this assignment, you will: + +Reinforce OOP concepts: class design, constructors, encapsulation, collections + +Practice instance methods vs. static methods + +Work with JSON parsing and REST APIs + +Design a simple console-based menu + +Improve Git workflow and project management +---- +## Prerequisites ✅ +Git + +Java (version 23 or 25) + +API key for movie database (e.g., TMDB) +--- +## Tasks Summary 📝 +Fork the repository and clone it locally + +Create and switch to a development branch + +Complete Part 1 (Rational.java) following the TODO comments + +Complete Part 2 (Movie.java, Genre.java, MovieService.java, Main.java) following the TODO comments + +Ensure the code compiles and runs correctly + +Commit and push regularly + +Submit a pull request from development to main +--- +## Evaluation Criteria ⚖️ +Functionality: Code compiles and runs without errors; all features work correctly + +Code Quality: Clean, readable, well-structured code with proper naming + +Understanding: You must be able to explain your implementation +--- +## Bonus Tasks ✒️ +Advanced search (title, genre, year, rating, etc.) + +Sorting options for movies + +Save/load favorite movies to/from a file + +Improved console menu design + +GUI version using JavaFX +--- +## Submission ⌛ +Deadline: May 1st (11 Ordibehesht) From a9d4b6d74733ba3f5f6e49c041efc8c255d5a318 Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 09:15:01 +0000 Subject: [PATCH 04/10] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f0ccbf..fd82983 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Implement addition, subtraction, multiplication, and division as instance method Implement addition, subtraction, multiplication, and division as static methods -# Note: Detailed TODO comments are provided inside Rational.java. +Note: Detailed TODO comments are provided inside Rational.java. --- ## Part 2: Movie Explorer 🎬 (Using API) In this part, you will develop a Java application that fetches movie data from an API and allows users to browse and search movies. @@ -46,7 +46,7 @@ Display the genres of a specific movie Implement a console menu in Main to receive user input and display data -# Note: Detailed TODO comments are provided inside each of the above source files. +Note: Detailed TODO comments are provided inside each of the above source files. --- ## Objectives ✏️ By completing this assignment, you will: From d2425a625ad8d98819acafc335a1ea4fc09a076c Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 09:16:44 +0000 Subject: [PATCH 05/10] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fd82983..975922b 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ Git Java (version 23 or 25) +Maven as a package manager + API key for movie database (e.g., TMDB) --- ## Tasks Summary 📝 From 75be64dc32a1b1a03c53ef7f26cdef3aedb0fd6d Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 09:18:30 +0000 Subject: [PATCH 06/10] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 975922b..912bb93 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ In this part, you will implement a Rational class that supports basic mathematic Tasks: Define fields for numerator and denominator -Implement a constructor and a reduce() method for simplification - Implement addition, subtraction, multiplication, and division as instance methods Implement addition, subtraction, multiplication, and division as static methods From b3778400a367f9400b6f1c3a40569e80e7453c44 Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 09:42:06 +0000 Subject: [PATCH 07/10] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 912bb93..f2cca2f 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,6 @@ Java (version 23 or 25) Maven as a package manager -API key for movie database (e.g., TMDB) --- ## Tasks Summary 📝 Fork the repository and clone it locally From 4c75b310f61d7fec51cd6940c589c3acfa5e8c44 Mon Sep 17 00:00:00 2001 From: Reyhane Noroozi Date: Thu, 23 Apr 2026 13:43:14 +0330 Subject: [PATCH 08/10] Update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f2cca2f..45ccefc 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Code Quality: Clean, readable, well-structured code with proper naming Understanding: You must be able to explain your implementation --- ## Bonus Tasks ✒️ +Parse the JSON returned by the `getMovieInfo` method into a MovieInfo entity, and then present the structured movie details based on the user‑provided movie ID. + Advanced search (title, genre, year, rating, etc.) Sorting options for movies From a61780dfc340fdc36796638c2eba22858afa6c73 Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 10:37:17 +0000 Subject: [PATCH 09/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 45ccefc..f4dac4b 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Save/load favorite movies to/from a file Improved console menu design GUI version using JavaFX + --- ## Submission ⌛ Deadline: May 1st (11 Ordibehesht) From cc9ad9520c2556b386a05e6772e5970afbc51257 Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Thu, 23 Apr 2026 10:37:58 +0000 Subject: [PATCH 10/10] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index f4dac4b..f6daf33 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ ## Third Assignment: Movie Explorer 🎬 + Rational Calculator 🧮 --- + Welcome to Your Third Assignment in the Advanced Programming Course! This assignment consists of two separate parts. You must complete both parts. + --- ## Part 1: Rational Class (Rational Numbers) @@ -16,6 +18,7 @@ Implement addition, subtraction, multiplication, and division as instance method Implement addition, subtraction, multiplication, and division as static methods Note: Detailed TODO comments are provided inside Rational.java. + --- ## Part 2: Movie Explorer 🎬 (Using API) In this part, you will develop a Java application that fetches movie data from an API and allows users to browse and search movies. @@ -45,6 +48,7 @@ Display the genres of a specific movie Implement a console menu in Main to receive user input and display data Note: Detailed TODO comments are provided inside each of the above source files. + --- ## Objectives ✏️ By completing this assignment, you will: @@ -58,6 +62,7 @@ Work with JSON parsing and REST APIs Design a simple console-based menu Improve Git workflow and project management + ---- ## Prerequisites ✅ Git @@ -81,6 +86,7 @@ Ensure the code compiles and runs correctly Commit and push regularly Submit a pull request from development to main + --- ## Evaluation Criteria ⚖️ Functionality: Code compiles and runs without errors; all features work correctly @@ -88,6 +94,7 @@ Functionality: Code compiles and runs without errors; all features work correctl Code Quality: Clean, readable, well-structured code with proper naming Understanding: You must be able to explain your implementation + --- ## Bonus Tasks ✒️ Parse the JSON returned by the `getMovieInfo` method into a MovieInfo entity, and then present the structured movie details based on the user‑provided movie ID.