Created
December 22, 2016 05:48
-
-
Save NaotoKumagai/b3aab66bf018d97daa19fbcbf9889f5f to your computer and use it in GitHub Desktop.
Day 12: Inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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