НУЖНО СДЕЛАТЬ ЧТОБЫ КЛАСС ВИДЕО СОДЕРЖАЛ ЖАНР А НЕ ЖАНР ВИДЕО // Класс Bid, наследующий от Content
// Наследует от Content добавляя уникальный атрибут bidName и методы для работы с ним
class Bid extends Content {
private String bidName;
public Bid(String bidName, String name, String genre, long viewCount, short rating, double duration, boolean isAvailable) {
super(name, genre, viewCount, rating, duration, isAvailable);
this.bidName = bidName;
}
public String getBidName() {
return bidName;
}
public void setBidName(String bidName) {
this.bidName = bidName;
}
}import java.util.Objects;
//Создает объект Video и использует его атрибуты, что создает связь между классами
// Класс Genre, который использует Video
class Genre {
private Video video;
private int time;
public Genre(String name, String genre, int time, long viewCount, short rating, double duration, boolean isAvailable) {
this.video = new Video(name, genre, viewCount, rating, duration, isAvailable);
this.time = time;
}
public String getName() {
return video.getName();
}
public String getGenre() {
return video.getGenre();
}
public long getViewCount() {
return video.getViewCount();
}
public short getRating() {
return video.getRating();
}
public double getDuration() {
return video.getDuration();
}
public boolean isAvailable() {
return video.isAvailable();
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Genre)) return false;
Genre genre = (Genre) o;
return time == genre.time && video.equals(genre.video);
}
@Override
public int hashCode() {
return Objects.hash(video, time);
}
}import java.util.Objects;
// Базовый класс
class Content {
protected String name;
protected String genre;
protected long viewCount;
protected short rating;
protected double duration;
protected boolean isAvailable;
public Content(String name, String genre, long viewCount, short rating, double duration, boolean isAvailable) {
this.name = name;
this.genre = genre;
this.viewCount = viewCount;
this.rating = rating;
this.duration = duration;
this.isAvailable = isAvailable;
}
public String getName() {
return name;
}
public String getGenre() {
return genre;
}
public long getViewCount() {
return viewCount;
}
public short getRating() {
return rating;
}
public double getDuration() {
return duration;
}
public boolean isAvailable() {
return isAvailable;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Content)) return false;
Content content = (Content) o;
return viewCount == content.viewCount &&
rating == content.rating &&
Double.compare(content.duration, duration) == 0 &&
isAvailable == content.isAvailable &&
Objects.equals(name, content.name) &&
Objects.equals(genre, content.genre);
}
@Override
public int hashCode() {
return Objects.hash(name, genre, viewCount, rating, duration, isAvailable);
}
}// Демонстрация работы
class RadioStationDemo {
public static void main(String[] args) {
Video genreVideo = new Video("MACAN - TSM", "Rap", 3, (short) 5, 40.0, true);
Bid bid = new Bid("FRIENDLY THUG 52 NGG - AMMO", "Street racing", "Underground rap", 32, (short) 35, 2.8, false);
Genre genre = new Genre("MACAN - TSM", "Rap", 120, 100, (short) 5, 40.0, true);
System.out.println("Video Name: " + genreVideo.getName());
System.out.println("Genre: " + genreVideo.getGenre());
System.out.println("View Count: " + genreVideo.getViewCount());
System.out.println("Rating: " + genreVideo.getRating());
System.out.println("Bid Name: " + bid.getBidName());
System.out.println("Bid Video Name: " + bid.getName());
System.out.println("Bid Genre: " + bid.getGenre());
System.out.println("Bid View Count: " + bid.getViewCount());
System.out.println("Bid Rating: " + bid.getRating());
System.out.println("Genre Video Name: " + genre.getName());
System.out.println("Genre Video Duration: " + genre.getDuration() + " min");
System.out.println("Genre Time: " + genre.getTime() + " seconds");
}
}// Класс Video, наследующий от Content
//Наследует от Content, добавляя функционал для видео
class Video extends Content {
public Video(String name, String genre, long viewCount, short rating, double duration, boolean isAvailable) {
super(name, genre, viewCount, rating, duration, isAvailable);
}
}