-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathStudent.java
More file actions
33 lines (27 loc) · 851 Bytes
/
Student.java
File metadata and controls
33 lines (27 loc) · 851 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
31
32
33
import java.util.ArrayList;
public class Student {
// Attributes
private String name;
private String id;
private int classYear;
private ArrayList<Course> classes;
public Student(String name, String id, int classYear) {
this.name = name;
this.id = id;
this.classYear = classYear;
this.classes = new ArrayList<>();
}
public String getName() {
return this.name;
}
public String toString() {
return this.name + " ID: " + this.id + " Class Year: " + this.classYear;
}
public static void main(String[] args) {
Student ab = new Student("Ab", "9909abc", 2014);
System.out.println(ab);
Course csc120 = new Course("OOP", "CSC120", "TR 10:50");
ab.classes.add(csc120);
System.out.println(ab.classes);
}
}