Day2_8段階目
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
public class EmployeeData {
|
public class EmployeeData {
|
||||||
|
|
||||||
private String idEmployee;
|
private String idEmployee;
|
||||||
private String nmEmployee;
|
private String nmEmployee;
|
||||||
private String knEmployee;
|
private String knEmployee;
|
||||||
@@ -8,9 +8,11 @@ public class EmployeeData {
|
|||||||
private String password;
|
private String password;
|
||||||
private String idDepartment;
|
private String idDepartment;
|
||||||
|
|
||||||
|
private static int empCount = 0;
|
||||||
|
|
||||||
//引数なしコンストラクタ
|
//引数なしコンストラクタ
|
||||||
public EmployeeData() {
|
public EmployeeData() {
|
||||||
|
empCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//6つの引数をもつコンストラクタ
|
//6つの引数をもつコンストラクタ
|
||||||
@@ -29,8 +31,14 @@ public class EmployeeData {
|
|||||||
this.setPassword(password);
|
this.setPassword(password);
|
||||||
this.setIdDepartment(idDepartment);
|
this.setIdDepartment(idDepartment);
|
||||||
|
|
||||||
|
empCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getEmpCount() {
|
||||||
|
return empCount;
|
||||||
|
}
|
||||||
|
|
||||||
public String getIdEmployee() {
|
public String getIdEmployee() {
|
||||||
return idEmployee;
|
return idEmployee;
|
||||||
}
|
}
|
||||||
@@ -44,6 +52,14 @@ public class EmployeeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setNmEmployee(String nmEmployee) {
|
public void setNmEmployee(String nmEmployee) {
|
||||||
|
|
||||||
|
//8段階目(空文字や空白だけの値が渡された場合は代入しない)
|
||||||
|
if (nmEmployee == null || nmEmployee.trim().isEmpty()) {
|
||||||
|
System.out.println("社員名が空のため設定できませんでした");
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.nmEmployee = nmEmployee;
|
this.nmEmployee = nmEmployee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class Main {
|
|||||||
Employees[4] = new EmployeeData();
|
Employees[4] = new EmployeeData();
|
||||||
|
|
||||||
Employees[0].setIdEmployee("10000");
|
Employees[0].setIdEmployee("10000");
|
||||||
Employees[0].setNmEmployee("山田龍也");
|
Employees[0].setNmEmployee("");
|
||||||
Employees[0].setKnEmployee("ヤマダタツヤ");
|
Employees[0].setKnEmployee("ヤマダタツヤ");
|
||||||
Employees[0].setMailAddress("yamada@hoge.jp");
|
Employees[0].setMailAddress("yamada@hoge.jp");
|
||||||
Employees[0].setPassword("aaa");
|
Employees[0].setPassword("aaa");
|
||||||
@@ -56,6 +56,8 @@ public class Main {
|
|||||||
System.out.println(Employees[i]);
|
System.out.println(Employees[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件");
|
||||||
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
@@ -76,6 +78,8 @@ public class Main {
|
|||||||
System.out.println(Employees[i]);
|
System.out.println(Employees[i]);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user