Eu fiz da seguinte forma. Classe PAI, Videos.
package br.com.alura.screenmatch.modelos;
public class Videos {
private String name;
private int releaseYear;
private String gender;
private String ageGroup;
private int durationInMinutes;
double sumOfReviews;
int totalRatings;
String systemMessage;
public void displayDatasheet () {
systemMessage = """
Este é um vídeo gratuito
""";
System.out.println(systemMessage);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public int getReleaseYear() {
return releaseYear;
}
public void setReleaseYear(int releaseYear) {
this.releaseYear = releaseYear;
}
public void setDurationInMinutes(int durationInMinutes) {
this.durationInMinutes = durationInMinutes;
}
public int getDurationInMinutes() {
return durationInMinutes;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getAgeGroup() {
return ageGroup;
}
public void setAgeGroup(String ageGroup) {
this.ageGroup = ageGroup;
}
public String getRatingMessage() {
if (sumOfReviews / totalRatings >= 9) {
return "Excelente";
} else if (sumOfReviews / totalRatings >= 8) {
return "Muito Bom";
} else if (sumOfReviews / totalRatings >= 7) {
return "Bom";
} else {
return "Razoável";
}
}
public String convertDurationToHours() {
int hours = durationInMinutes / 60;
int remainingMinutes = durationInMinutes % 60;
return hours + "h" + ":" + String.format("%02d", remainingMinutes) + "min";
}
public void evaluateVideo (double rating) {
sumOfReviews += rating;
totalRatings++;
}
public String ratingAverage() {
if (totalRatings > 0) {
return String.format("%.1f\n", sumOfReviews / totalRatings).replace("\n", "");
} else {
return "0.0";
}
}
}