2日目の8段階目終了

This commit is contained in:
2026-09-18 10:00:12 +09:00
parent 5358280624
commit 60da179895
2 changed files with 38 additions and 26 deletions

View File

@@ -49,6 +49,11 @@ public class EmployeeData extends BaseData {
public void setNmEmployee(String nmEmployee) { public void setNmEmployee(String nmEmployee) {
this.nmEmployee = nmEmployee; this.nmEmployee = nmEmployee;
if (nmEmployee == null || nmEmployee.strip().isEmpty()) {
System.out.println("社員名が空のため設定できませんでした");
return;
}
} }
public String getKnEmployee() { public String getKnEmployee() {

View File

@@ -6,7 +6,7 @@ public class Main {
// System.out.println("検索したい社員IDを入力してください(終了する場合は0)"); // System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
// String input = scanner.nextLine(); // String input = scanner.nextLine();
// BaseData[] employees = new BaseData[5]; BaseData[] employees = new BaseData[5];
// BaseData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10"); // BaseData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
BaseData[] allData = new BaseData[11]; BaseData[] allData = new BaseData[11];
// //
@@ -23,28 +23,28 @@ public class Main {
allData[9] = new DepartmentData("14", "教育事業部"); allData[9] = new DepartmentData("14", "教育事業部");
allData[10] = new DepartmentData("15", "営業企画部"); allData[10] = new DepartmentData("15", "営業企画部");
String targetDeptId = ""; // String targetDeptId = "";
//
for (int i = 0; i < allData.length; i++) { // for (int i = 0; i < allData.length; i++) {
//
if (allData[i] instanceof DepartmentData) { // if (allData[i] instanceof DepartmentData) {
DepartmentData dept = (DepartmentData) allData[i]; // DepartmentData dept = (DepartmentData) allData[i];
//
if (dept.getNmDepartment().equals("システム開発事業部")) { // if (dept.getNmDepartment().equals("システム開発事業部")) {
targetDeptId = dept.getIdDepartment(); // targetDeptId = dept.getIdDepartment();
break; // break;
} // }
} // }
} // }
//
for (int i = 0; i < allData.length; i++) { // for (int i = 0; i < allData.length; i++) {
if (allData[i] instanceof EmployeeData) { // if (allData[i] instanceof EmployeeData) {
EmployeeData emp = (EmployeeData) allData[i]; // EmployeeData emp = (EmployeeData) allData[i];
if (emp.getIdDepartment().equals(targetDeptId)) { // if (emp.getIdDepartment().equals(targetDeptId)) {
System.out.println(emp.getNmEmployee() + "\t" + emp.getMailAddress()); // System.out.println(emp.getNmEmployee() + "\t" + emp.getMailAddress());
} // }
} // }
} // }
// int count = 0; // int count = 0;
// int countt = 0; // int countt = 0;
@@ -71,9 +71,16 @@ public class Main {
// employees[4] = new EmployeeData("10004", "三宅武", "ミタケタケシ", "miya@hoge.jp", "eee", "13"); // employees[4] = new EmployeeData("10004", "三宅武", "ミタケタケシ", "miya@hoge.jp", "eee", "13");
// // // //
// // for (int i = 0; i < employees.length; i++) {
// System.out.println(allData[i]);
// }
// System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件"); // System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件");
if (allData[0] instanceof EmployeeData) {
EmployeeData sampleEmp = (EmployeeData) allData[0];
sampleEmp.setNmEmployee("");
}
// String serchId1 = "10002"; // String serchId1 = "10002";
// System.out.println(serchId1 + "を検索します"); // System.out.println(serchId1 + "を検索します");
// boolean bo = false; // boolean bo = false;