10/15作業分
This commit is contained in:
31
Student.java
31
Student.java
@@ -1,10 +1,31 @@
|
||||
package misson1014;
|
||||
|
||||
public class Student {
|
||||
int studentId;
|
||||
String name;
|
||||
int studentId;
|
||||
String name;
|
||||
//staticフィールド
|
||||
static int studentCount = 0;
|
||||
|
||||
//コンストラクタ
|
||||
public Student(int studentId, String name) {
|
||||
//フィールド代入
|
||||
this.studentId = studentId;
|
||||
this.name = name;
|
||||
studentCount++;
|
||||
}
|
||||
|
||||
//学生情報
|
||||
void printProfile() {
|
||||
|
||||
System.out.println(
|
||||
"学籍番号:" + this.studentId
|
||||
+ " 名前:" + this.name);
|
||||
}
|
||||
|
||||
//現在の学生数用staticメソッド
|
||||
public static int getStudentCount() {
|
||||
return studentCount;
|
||||
|
||||
}
|
||||
|
||||
void printProfile() {
|
||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user