2日目_段階3完了
This commit is contained in:
@@ -2,29 +2,30 @@
|
||||
public class BasicCheck2 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
Student student = new Student();
|
||||
// Student student = new Student(3,"a");
|
||||
//Student型のstudentを宣言、インスタンスを代入する
|
||||
Student student1 = new Student();
|
||||
Student student2 = new Student();
|
||||
Student student3 = new Student();
|
||||
Student student1 = new Student(1,"鈴木一郎");
|
||||
Student student2 = new Student(2, "田中花子");
|
||||
Student student3 = new Student(3,"佐藤次郎");
|
||||
|
||||
|
||||
student1.studentId = 1;
|
||||
student1.name = "鈴木一郎";
|
||||
//studentIDに1,nameに鈴木一郎を代入
|
||||
|
||||
student2.studentId = 2;
|
||||
student2.name ="田中花子";
|
||||
|
||||
student3.studentId = 3;
|
||||
student3.name ="佐藤次郎";
|
||||
|
||||
// student1.studentId = 1;
|
||||
// student1.name = "鈴木一郎";
|
||||
// //studentIDに1,nameに鈴木一郎を代入
|
||||
//
|
||||
// student2.studentId = 2;
|
||||
// student2.name ="田中花子";
|
||||
//
|
||||
// student3.studentId = 3;
|
||||
// student3.name ="佐藤次郎";
|
||||
//
|
||||
|
||||
|
||||
|
||||
//studentのprintProfileメソッドを呼び出す
|
||||
student.printProfile();
|
||||
student1.printProfile();
|
||||
student2.printProfile();
|
||||
student3.printProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ public class Student {//クラス新規作成
|
||||
|
||||
void printProfile() {//メソッドを宣言・以下の内容をsysoで出力
|
||||
|
||||
for(int i = 0; i <= 3; i++) {
|
||||
// for(int i = 0; i <= 3; i++) {
|
||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
// }
|
||||
|
||||
// System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
@@ -18,16 +18,12 @@ public class Student {//クラス新規作成
|
||||
public Student(int studentId, String name) { //コンストラクタを追加
|
||||
this.studentId = studentId; //渡された引数をそれぞれ対応するフィールドに代入する
|
||||
this.name = name;
|
||||
// studentCount++;
|
||||
studentCount++;
|
||||
}
|
||||
|
||||
public Student() {
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
}
|
||||
|
||||
|
||||
public int getStudentCount() {
|
||||
studentCount++;
|
||||
public static int getStudentCount() {
|
||||
// studentCount++;
|
||||
return studentCount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user