2日目_7段階

This commit is contained in:
2026-09-24 10:40:00 +09:00
parent 2094ebac56
commit b13acdba05
2 changed files with 25 additions and 13 deletions

View File

@@ -9,6 +9,9 @@ public class EmployeeData {
private String password;
private String idDepartment;
//staticをつけたフィールドはクラス変数:全てのインスタンスで共有される変数
public static int empCount = 0;
// boolean isMatchID = isMatchId(idEmployee);//IdEmployeeが一致するか判断
//idEmployee「ID」を取得するgetter
@@ -82,6 +85,7 @@ public class EmployeeData {
this.mailAddress = mailAddress;
this.password = password;
this.idDepartment = idDepartment;
empCount++;
}
// public boolean isMatchId(String id) {
@@ -98,20 +102,26 @@ public class EmployeeData {
// }
public EmployeeData() {
empCount++;
// TODO 自動生成されたコンストラクター・スタブ
}
void showinfo() { //showinfo->toStringにメソッド名変更 + アクセス修飾子publicつける
// this.idEmployee = idEmployee;
System.out.println(this.idEmployee + "\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + this.mailAddress
+ "\t" + this.password + "\t" + this.idDepartment);
public static int getEmpCount() { //empCountの値を返せるようにする
return empCount;
}
// void showinfo() { //showinfo->toStringにメソッド名変更 + アクセス修飾子publicつける
// // this.idEmployee = idEmployee;
// System.out.println(this.idEmployee + "\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + this.mailAddress
// + "\t" + this.password + "\t" + this.idDepartment);
//
// }
@Override
public String toString() {
return (this.idEmployee +"\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + this.mailAddress
+ "\t" + this.password + "\t" + this.idDepartment);
+ "\t" + this.password + "\t" + this.idDepartment);
}
}

View File

@@ -12,7 +12,7 @@ public class Main {
// employees[1] = new Employee;
employees[0] = new EmployeeData();
// employees[0] = new EmployeeData();
employees[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
@@ -31,7 +31,7 @@ public class Main {
// employees[0].idDepartment = "10";
//
employees[1] = new EmployeeData();
// employees[1] = new EmployeeData();
employees[1] = new EmployeeData("10000", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
// employees[1].setIdEmployee ( "10001");
@@ -49,7 +49,7 @@ public class Main {
// employees[1].idDepartment = "10";
//
employees[2] = new EmployeeData();//各employee[]をコメントアウトしていたからエラー! employeeに何の箱を入れるかを表記
// employees[2] = new EmployeeData();//各employee[]をコメントアウトしていたからエラー! employeeに何の箱を入れるかを表記
employees[2] = new EmployeeData("10002", "麻枝文明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
// employees[2].setIdEmployee("10002");
@@ -66,7 +66,7 @@ public class Main {
// employees[2].password = "ccc";
// employees[2].idDepartment = "11";
// //
employees[3] = new EmployeeData();
// employees[3] = new EmployeeData();
employees[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
// employees[3].setIdEmployee("10003");
@@ -83,7 +83,7 @@ public class Main {
// employees[3].password = "ddd";
// employees[3].idDepartment = "12";
// //
employees[4] = new EmployeeData();
// employees[4] = new EmployeeData();
employees[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "13");
// employees[4].setIdEmployee("10004");
@@ -135,6 +135,8 @@ public class Main {
System.out.println(employees[2]);
System.out.println(employees[3]);
System.out.println(employees[4]);
//5人分のインスタンスをすべて生成し終えた後にクラス名から呼び出し、件数表示
System.out.println("現在の社員データ件数:" + EmployeeData.empCount +"件");
// employees[0].showinfo();
// employees[1].showinfo();
// employees[2].showinfo();