段階3完了しました。
This commit is contained in:
@@ -3,11 +3,15 @@ public class BasicCheck2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
Student student = new Student();
|
||||
student.studentId = 1;
|
||||
student.name = "鈴木一郎";
|
||||
student.printProfile();
|
||||
Student student1 = new Student(1,"鈴木一郎");
|
||||
Student student2 = new Student(2,"田中花子");
|
||||
Student student3 = new Student(3,"佐藤次郎");
|
||||
student1.printProfile();
|
||||
student2.printProfile();
|
||||
student3.printProfile();
|
||||
int total=Student.getStudentCount();
|
||||
System.out.println("現在の生徒数" + total + "人");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,5 +5,14 @@ public class Student {
|
||||
|
||||
void printProfile() {
|
||||
System.out.println("学籍番号;"+this.studentId+" 名前;"+this.name);
|
||||
}
|
||||
}
|
||||
static int studentCount = 0;
|
||||
public Student (int studentId,String name){
|
||||
this.studentId = studentId;
|
||||
this.name = name;
|
||||
studentCount++;
|
||||
}
|
||||
static int getStudentCount() {
|
||||
return studentCount;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user