Day2、3段階目完了
This commit is contained in:
@@ -2,20 +2,20 @@
|
||||
public class BasicCheck2 {
|
||||
public static void main(String[] args) {
|
||||
//変数宣言
|
||||
Student student = new Student();
|
||||
Student students = 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();
|
||||
|
||||
//Student.getStudentCount();
|
||||
|
||||
Student students1 = new Student(1, "鈴木一郎");
|
||||
Student students2 = new Student(2, "田中花子");
|
||||
Student students3 = new Student(3, "佐藤次郎");
|
||||
|
||||
students1.printProfile();
|
||||
students2.printProfile();
|
||||
students3.printProfile();
|
||||
|
||||
System.out.println("現在の生徒数:" + Student.getstudentCount() + "人");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ public class Student {
|
||||
int studentId;
|
||||
String name;
|
||||
//フィールド追加
|
||||
static int studentCount = 0;
|
||||
static int studentCount = 3;
|
||||
|
||||
//メソッド宣言
|
||||
void printProfile() {
|
||||
@@ -16,8 +16,12 @@ public class Student {
|
||||
this.studentId = studentId;
|
||||
this.name = name;
|
||||
}
|
||||
public Student() {
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
}
|
||||
|
||||
//コントラクタ追加
|
||||
public static int studentCount() {
|
||||
public static int getstudentCount() {
|
||||
return studentCount;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user