52 lines
1.0 KiB
Java
52 lines
1.0 KiB
Java
import java.util.Objects;
|
|
|
|
public class Movie {
|
|
private String title;
|
|
private double rating;
|
|
private int year;
|
|
|
|
public Movie(String title, double rating, int year)
|
|
{
|
|
this.title = title;
|
|
this.rating = rating;
|
|
this.year = year;
|
|
}
|
|
|
|
public String getTitle()
|
|
{
|
|
return title;
|
|
}
|
|
|
|
public double getRating()
|
|
{
|
|
return rating;
|
|
}
|
|
|
|
public int getYear()
|
|
{
|
|
return year;
|
|
}
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return "Movie: " + title + ", Rating: " + rating + ", Year: " + year;
|
|
}
|
|
|
|
@Override
|
|
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 &&
|
|
year == movie.year &&
|
|
Objects.equals(title, movie.title);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode()
|
|
{
|
|
return Objects.hash(title, rating, year);
|
|
}
|
|
} |