3段階目(Studentクラスにコンストラクタとstaticメンバを追加しよう)
This commit is contained in:
@@ -2,8 +2,19 @@
|
||||
public class Student {
|
||||
int studentId;
|
||||
String name;
|
||||
static int studentCount = 0;
|
||||
|
||||
void printProfile() {
|
||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
|
||||
public Student(int studentId, String name) {
|
||||
this.studentId = studentId;
|
||||
this.name = name;
|
||||
studentCount++;
|
||||
}
|
||||
|
||||
public static int getStudentCount() {
|
||||
return studentCount;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user