-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
30 lines (24 loc) · 853 Bytes
/
Copy pathStudent.java
File metadata and controls
30 lines (24 loc) · 853 Bytes
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
package oop11_arraylist;
import java.util.ArrayList;
public class Student {
private int id;
private int totalScore;
private String name;
public ArrayList<Subject> courses = new ArrayList<>();
public Student(int id, String name) {
this.id = id;
this.name = name;
}
public void addSubject(String subjectName, int score) {
courses.add(new Subject(subjectName, score));
totalScore += score;
}
public void showStudentInfo() {
for(Subject subject : courses) {
System.out.print(name + " 학생의");
System.out.print(" " + subject.getSubjectName() + " 과목 성적은 ");
System.out.println(subject.getScore() + "점 입니다.");
}
System.out.println(name + " 학생의 총점은 " + totalScore + "점 입니다.");
}
}