2 Commits
Author SHA1 Message Date
Saba_frm 13266e501e development 2026-05-02 13:39:41 +03:30
Saba_frm f2be2ee51c develop 2026-05-02 13:29:35 +03:30
4 changed files with 130 additions and 22 deletions
View File
+106 -4
View File
@@ -6,18 +6,46 @@ import java.util.List;
* Model class representing a movie * Model class representing a movie
* Fields: id, title, genres, images * Fields: id, title, genres, images
*/ */
public class Movie { public class Movie {
private Long id; private Long id;
private String title; private String title;
private List<String> genres; private List<String> genres;
private List<String> images; private List<String> images;
private String year; private String year;
private String imdb_rating; private String imdb_id;
private String rated;
private String released;
private String runtime;
private String director;
private String writer;
private String actors;
private String plot;
private String language;
private String country; private String country;
private String awards;
private String poster;
private Double imdb_rating;
private String imdb_votes;
private String type;
private String metascore;
private String genre;
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public Movie(Long id, String title, List<String> genres, List<String> images, public Movie(Long id, String title, List<String> genres, List<String> images,
String year, String imdb_rating, String country) String year, Double imdb_rating, String country)
{ {
this.id = id; this.id = id;
this.title = title; this.title = title;
@@ -28,6 +56,22 @@ public class Movie {
this.country = country; this.country = country;
} }
public String getDirector() { return director; }
public String getWriter() { return writer; }
public String getActors() { return actors; }
public String getPlot() { return plot; }
public String getLanguage() { return language; }
public String getAwards() { return awards; }
public String getPoster() { return poster; }
public String getImdb_votes() { return imdb_votes; }
public String getType() { return type; }
public String getMetascore() { return metascore; }
public String getRated() { return rated; }
public String getReleased() { return released; }
public String getRuntime() { return runtime; }
public String getImdb_id() { return imdb_id; }
public Movie(Long id, String title) public Movie(Long id, String title)
{ {
this.id = id; this.id = id;
@@ -86,12 +130,13 @@ public class Movie {
this.year = year; this.year = year;
} }
public String getImdb_rating()
public Double getImdb_rating()
{ {
return imdb_rating; return imdb_rating;
} }
public void setImdb_rating(String imdb_rating) public void setImdb_rating(Double imdb_rating)
{ {
this.imdb_rating = imdb_rating; this.imdb_rating = imdb_rating;
} }
@@ -106,6 +151,63 @@ public class Movie {
this.country = country; this.country = country;
} }
public void setDirector(String director) {
this.director = director;
}
public void setWriter(String writer) {
this.writer = writer;
}
public void setActors(String actors) {
this.actors = actors;
}
public void setPlot(String plot) {
this.plot = plot;
}
public void setLanguage(String language) {
this.language = language;
}
public void setAwards(String awards) {
this.awards = awards;
}
public void setPoster(String poster) {
this.poster = poster;
}
public void setImdb_votes(String imdb_votes) {
this.imdb_votes = imdb_votes;
}
public void setType(String type) {
this.type = type;
}
public void setMetascore(String metascore) {
this.metascore = metascore;
}
public void setRated(String rated) {
this.rated = rated;
}
public void setReleased(String released) {
this.released = released;
}
public void setRuntime(String runtime) {
this.runtime = runtime;
}
public void setImdb_id(String imdb_id) {
this.imdb_id = imdb_id;
}
@Override @Override
public String toString() public String toString()
{ {
+18 -12
View File
@@ -220,24 +220,31 @@ public class MovieService {
try try
{ {
JsonObject root = JsonParser.parseString(jsonResponse).getAsJsonObject();
Gson gson = new Gson(); Gson gson = new Gson();
Movie movie = gson.fromJson(root, Movie.class); Movie movie = gson.fromJson(jsonResponse, Movie.class);
System.out.println("\n======================================================================="); System.out.println("\n=======================================================================");
System.out.println(" " + movie.getTitle() + " (" + movie.getYear() + ")"); System.out.println(" " + movie.getTitle() + " (" + movie.getYear() + ")");
System.out.println("======================================================================="); System.out.println("=======================================================================\n");
System.out.println("Rating: " + movie.getImdb_rating()); System.out.println("Rating: " + movie.getImdb_rating() + "/10 | Votes: " + movie.getImdb_votes());
System.out.println("Country: " + movie.getCountry());
System.out.println("Year: " + movie.getYear());
if (movie.getGenres() != null) System.out.println("Director: " + movie.getDirector());
System.out.println("Genres: " + String.join(", ", movie.getGenres())); System.out.println("Cast: " + movie.getActors());
System.out.println("\n======================================================================="); if (movie.getGenres() != null) {
System.out.println(); System.out.println("Genre: " + String.join(", ", movie.getGenres()));
}
System.out.println("Runtime: " + movie.getRuntime() + " | Rated: " + movie.getRated());
System.out.println("Country: " + movie.getCountry() + " | Released: " + movie.getReleased());
System.out.println("Plot: " + movie.getPlot());
System.out.println("Awards: " + movie.getAwards());
System.out.println("=======================================================================\n");
} }
catch (Exception e) catch (Exception e)
@@ -247,5 +254,4 @@ public class MovieService {
} }
} }