public class Movie
{
String title;
int year;
int duration;
boolean included;
double sumEvaluation;
int totalEvaluations;
@Override /*Metodo crear ficha tecnica*/
public String toString() {
return "The name of the movie is "+title+"\t"+year+"\t"+duration+"\t"+included;
}
/*Metodo para evaluar */
public double evaluation (double nota){
totalEvaluations++;
return sumEvaluation+=nota;
}
/*Metodo para calcular media */
public double calculateAverage(){
return sumEvaluation/totalEvaluations;
}
}
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
Movie movie = new Movie(); //Llamo a la instancia
movie.title = "COCO";
movie.year = 2019;
System.out.println(movie.toString());
movie.title = "MATRIX";
movie.year = 1999;
System.out.println(movie.toString()); //llamo el menu
System.out.println(movie.evaluation(10)); //LLamo metodo que suma las evaluacioness
System.out.println(movie.evaluation(10));
System.out.println(movie.totalEvaluations);
System.out.println("MEDIA "+movie.calculateAverage());
}
}