Skip to content

Instantly share code, notes, and snippets.

@NaotoKumagai
Created December 22, 2016 05:48
Show Gist options
  • Save NaotoKumagai/b3aab66bf018d97daa19fbcbf9889f5f to your computer and use it in GitHub Desktop.
Save NaotoKumagai/b3aab66bf018d97daa19fbcbf9889f5f to your computer and use it in GitHub Desktop.
Day 12: Inheritance
class Student extends Person{
private int[] testScores;
Student(String firstName, String lastName, int id, int[] testScores) {
super(firstName, lastName,id);
this.testScores = testScores;
}
public String calculate() {
double avarage = java.util.stream.IntStream.of(testScores)
.average()
.getAsDouble();
return 90 <= avarage && avarage <= 100 ? "O" :
80 <= avarage && avarage < 90 ? "E" :
70 <= avarage && avarage < 80 ? "A" :
55 <= avarage && avarage < 70 ? "P" :
40 <= avarage && avarage < 55 ? "D" :
avarage < 40 ? "T" : "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment