metodo movie:
package com.example;
public class Movie {
String name;
int yearOfRelease;
boolean includedInThePlan;
double sumOfRatings; // soma das avaliações;
int totalReviews;
int durationInMinutes;
void showTechnical() {
System.out.println("\nName: " + this.name);
System.out.println("Year of release: " + this.yearOfRelease);
}
void evaluates(double note) {
sumOfRatings += note;
totalReviews++;
}
double getsTheAverage() {
return sumOfRatings / totalReviews;
}
}
A seguir, Main:
package com.example;
public class Main {
public static void main(String[] args) {
Movie theHangover = new Movie();
theHangover.name = "The Hangover";
theHangover.yearOfRelease = 1999;
theHangover.durationInMinutes = 120;
theHangover.showTechnical();
theHangover.evaluates(8);
theHangover.evaluates(5);
theHangover.evaluates(10);
System.out.println("Sum of ratings: " + theHangover.sumOfRatings); // Soma das avaliaçoes;
System.out.println("Total Reviews: " + theHangover.totalReviews);
System.out.println(theHangover.getsTheAverage());
}
}
Eu criei as variáveis em inglês, pq quero me habituar ao idioma e aprender. Esse é um dos passos.