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