3日目の6段階目終了

This commit is contained in:
2026-09-17 14:57:00 +09:00
parent 70b3359a0d
commit 59fd7f7ad3
2 changed files with 112 additions and 61 deletions

View File

@@ -0,0 +1,39 @@
public class DepartmentData extends BaseData {
private String idDepartment, nmDepartment;
public DepartmentData(String idDepartment,String nmDepartment) {
this.setIdDepartment(idDepartment);
this.setNmDepartment(nmDepartment);
return;
}
public String getIdDepartment() {
return idDepartment;
}
public void setIdDepartment(String idDepartment) {
this.idDepartment = idDepartment;
}
public String getNmDepartment() {
return nmDepartment;
}
public void setNmDepartment(String nmDepartment) {
this.nmDepartment = nmDepartment;
}
@Override
public String toString() {
return getIdDepartment() + "\t" + getNmDepartment();
}
public String toCSV() {
return getIdDepartment() + "," + getNmDepartment();
}
public String getPrimaryKeyValue() {
return getIdDepartment();
}
}

View File

@@ -1,31 +1,45 @@
import java.util.Scanner;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
while (true) { // while (true) {
Scanner scanner = new Scanner(System.in); // Scanner scanner = new Scanner(System.in);
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];
//
allData[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
allData[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
allData[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
allData[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
allData[4] = new EmployeeData("10004", "三宅武", "ミタケタケシ", "miya@hoge.jp", "eee", "13");
allData[5] = new DepartmentData("10", "役員");
allData[6] = new DepartmentData("11", "人事・総務部");
allData[7] = new DepartmentData("12", "経理");
allData[8] = new DepartmentData("13", "システム開発事業部");
allData[9] = new DepartmentData("14", "教育事業部");
allData[10] = new DepartmentData("15", "営業企画部");
for (int i = 0; i < allData.length; i++) {
System.out.println(allData[i]);
}
// employees[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
// employees[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
// employees[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
// employees[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
// employees[4] = new EmployeeData("10004", "三宅武", "ミタケタケシ", "miya@hoge.jp", "eee", "13");
// //
employees[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
employees[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
employees[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
employees[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
employees[4] = new EmployeeData("10004", "三宅武", "ミタケタケシ", "miya@hoge.jp", "eee", "13");
//
// for (int i = 0; i < employees.length; i++) {
//
// System.out.println(employees[i]);
//
// }
// //
// System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件"); // System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件");
String serchId1 = "10002"; // String serchId1 = "10002";
// System.out.println(serchId1 + "を検索します"); // System.out.println(serchId1 + "を検索します");
// boolean bo = false; // boolean bo = false;
// for (int i = 0; i < employees.length; i++) { // for (int i = 0; i < employees.length; i++) {
@@ -36,7 +50,7 @@ public class Main {
// //
// } // }
// System.out.println(bo); // System.out.println(bo);
String serchId2 = "99999"; // String serchId2 = "99999";
// System.out.println(serchId2 + "を検索します"); // System.out.println(serchId2 + "を検索します");
// boolean bl = false; // boolean bl = false;
// for (int i = 0; i < employees.length; i++) { // for (int i = 0; i < employees.length; i++) {
@@ -47,26 +61,24 @@ public class Main {
// } // }
// System.out.println(bl); // System.out.println(bl);
boolean a = false; // boolean a = false;
for (int i = 0; i < employees.length; i++) { // for (int i = 0; i < employees.length; i++) {
if (((EmployeeData) employees[i]).isMatchId(input)) { // if (((EmployeeData) employees[i]).isMatchId(input)) {
a = true; // a = true;
System.out.println(employees[i]); // System.out.println(employees[i]);
break; // break;
//
} // }
} // }
if (!a) { // if (!a) {
System.out.println("該当する社員が見つかりませんでした"); // System.out.println("該当する社員が見つかりませんでした");
} // }
if (input.equals("0")) { // if (input.equals("0")) {
System.out.println("システムを終了します"); // System.out.println("システムを終了します");
break; // break;
} // }
// System.out.println(employee.toCSV()); // System.out.println(employee.toCSV());
// System.out.println(employee.getPrimaryKeyValue()); // System.out.println(employee.getPrimaryKeyValue());
} }
}
} }