HW3 all Right

This commit is contained in:
2025mohseni
2026-06-05 23:54:22 +03:30
parent bd0d2de7d5
commit 95b1888e50
2 changed files with 47 additions and 3 deletions
+2 -1
View File
@@ -101,8 +101,9 @@ public class RationalTest {
try { try {
Rational zero = new Rational(0, 1); Rational zero = new Rational(0, 1);
Rational divisionByZero = r1.divide(zero); Rational divisionByZero = r1.divide(zero);
} catch (ArithmeticException e) { } catch (IllegalArgumentException e) {
System.out.println("Caught division by zero: " + e.getMessage()); System.out.println("Caught division by zero: " + e.getMessage());
} }
} }
} }
+45 -2
View File
@@ -25,11 +25,25 @@ public class Movie {
private List<String> genres; private List<String> genres;
private List<String> images; private List<String> images;
private String metascore;
@SerializedName("imdb_id")
private String imdbId;
public void setImdbRating(String imdbRating) {
this.imdbRating = imdbRating;
}
private String released;
private String type;
private String writer;
// Constructor کامل // Constructor کامل
public Movie(Long id, String title, String year, String country, String imdbRating, String imdbVotes, public Movie(Long id, String title, String year, String country, String imdbRating, String imdbVotes,
String director, String actors, String plot, String awards, String rated, String runtime, String director, String actors, String plot, String awards, String rated, String runtime,
List<String> genres, List<String> images) { List<String> genres, List<String> images) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.year = year; this.year = year;
@@ -58,7 +72,35 @@ public class Movie {
public String getTitle() { return title; } public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; } public void setTitle(String title) { this.title = title; }
public String getYear() { return year; } public String getYear() { return year; }
public void setYear(String year) { this.year = year; } public void setYear(String year){ this.year = year;}
public String getCountry() { return country; }
public void setCountry(String country) { this.country = country; }
public List<String> getGenres() { return genres; }
public void setGenres(List<String> genres) { this.genres = genres; }
public List<String> getImages() { return images; }
public void setImages(List<String> images) { this.images = images; }
public String getMetascore() { return metascore; }
public void setMetascore(String metascore) { this.metascore = metascore; }
public String getImdbId() { return imdbId; }
public void setImdbId(String imdbId) { this.imdbId = imdbId; }
public String getReleased() { return released; }
public void setReleased(String released) { this.released = released; }
public String getType() { return type; }
public void setType(String type) { this.type = type; }
public void setImdbVotes(String imdbVotes) {
this.imdbVotes = imdbVotes;
}
public String getWriter() { return writer; }
public void setWriter(String writer) { this.writer = writer; }
public String getImdbRating() { return imdbRating; } public String getImdbRating() { return imdbRating; }
public String getImdbVotes() { return imdbVotes; } public String getImdbVotes() { return imdbVotes; }
public String getDirector() { return director; } public String getDirector() { return director; }
@@ -67,5 +109,6 @@ public class Movie {
public String getAwards() { return awards; } public String getAwards() { return awards; }
public String getRated() { return rated; } public String getRated() { return rated; }
public String getRuntime() { return runtime; } public String getRuntime() { return runtime; }
public String getGenre() { return genres != null ? String.join(", ", genres) : "N/A"; } public String getGenre() { return genres != null ? String.join(", ", genres) : "N/A";
}
} }