This commit is contained in:
2026-05-21 15:25:31 +03:30
parent 7e0386ce16
commit 01191c5261
3 changed files with 106 additions and 41 deletions
+26 -13
View File
@@ -5,35 +5,48 @@ public class Movie {
private double rating;
private int year;
public Movie(String title, double rating, int year) {
// TODO: Initialize the instance variables (this.title, this.rating, this.year)
// with the values passed as arguments to this constructor.
public Movie(String title, double rating, int year)
{
this.title = title;
this.rating = rating;
this.year = year;
}
public String getTitle() {
public String getTitle()
{
return title;
}
public double getRating() {
public double getRating()
{
return rating;
}
public int getYear() {
public int getYear()
{
return year;
}
@Override
public String toString() {
// TODO: Return a string representation of the movie matching the exact required format.
// Example format: "Movie: The Godfather, Rating: 9.2, Year: 1972"
return "";
public String toString()
{
return "Movie: " + title + ", Rating: " + rating + ", Year: " + year;
}
@Override
public boolean equals(Object o) {
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Movie movie = (Movie) o;
return Double.compare(movie.rating, rating) == 0 && movie.year == year && Objects.equals(title, movie.title);
return Double.compare(movie.rating, rating) == 0 &&
year == movie.year &&
Objects.equals(title, movie.title);
}
}
@Override
public int hashCode()
{
return Objects.hash(title, rating, year);
}
}