-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
29 lines (24 loc) · 626 Bytes
/
Student.java
File metadata and controls
29 lines (24 loc) · 626 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
package ArrayList;
import java.util.ArrayList;
public class Student {
String name;
int id;
ArrayList<Book> bookList;
Student(int id, String name){
this.name = name;
this.id = id;
// 학생이 생성될때 리스트도 생성
bookList = new ArrayList<>();
}
void addBook(String bookName, String author) {
bookList.add(new Book(bookName, author));
}
public void showStudentInfo() {
System.out.print(name+" 학생이 읽은 책은 : ");
for(int i=0; i<bookList.size(); i++) {
System.out.print(bookList.get(i).bookName+" ");
}
System.out.print("입니다");
System.out.println();
}
}