-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSport student
42 lines (38 loc) · 1.13 KB
/
Sport student
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Student {
protected String studentName;
protected int academicScore;
public Student(String studentName, int academicScore) {
this.studentName = studentName;
this.academicScore = academicScore;
// this.sportsScore = sportsScore;
}
public void displayAcademicScore() {
System.out.println("Academic Score of: " + studentName + ":" + academicScore);
}
}
class Sports{
protected int sportsScore;
public Sports(int sportsScore){
this.sportsScore = sportsScore;
}
public void displaySportsScore(){
System.out.println("Sports Score: "+ sportsScore);
}
}
class Result extends Student {
private Sports sports;
public Result(String studentName, int academicScore, int sportsScore){
super(studentName, academicScore);
this.sports = new Sports(sportsScore);
}
public void displayScores(){
super.displayAcademicScore();
sports.displaySportsScore();
}
}
class Output{
public static void main(String[] args){
Result result = new Result("John",85,90);
result.displayScores();
}
}