一日目段階8完了しました

This commit is contained in:
2026-09-18 09:49:49 +09:00
parent 139165eaa5
commit 91689ca055
2 changed files with 31 additions and 23 deletions

View File

@@ -107,7 +107,7 @@ public class EmployeeData extends BaseDate {
return idEmployee; return idEmployee;
} }
public boolean isMatchId(String id) { public boolean isMatchId(String id) {
System.out.println(id + "を検索します"); // System.out.println(id + "を検索します");
if(id.equals(idEmployee)) { if(id.equals(idEmployee)) {
return true; return true;
} else { } else {

View File

@@ -1,16 +1,16 @@
import java.util.Scanner;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
EmployeeData[] employee = new EmployeeData[5]; EmployeeData[] employee = new EmployeeData[5];
employee[0] = new EmployeeData("10000","山田","ヤマダタツヤ","yamada@hoge.jp","aaa","10"); employee[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
employee[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "11"); employee[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "11");
employee[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "12"); employee[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "12");
employee[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "13"); employee[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "13");
employee[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "14"); employee[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "14");
// for (int i=0; i<=4; i++ ) { // for (int i=0; i<=4; i++ ) {
// System.out.println(employee[i]); // System.out.println(employee[i]);
// } // }
@@ -19,11 +19,19 @@ public class Main {
// //
// System.out.println(employee[0].toCSV()); // System.out.println(employee[0].toCSV());
// System.out.println(employee[0].getPrimaryKeyValue()); // System.out.println(employee[0].getPrimaryKeyValue());
System.out.println("検索したい社員IDを入力してください");
boolean bo= employee[0].isMatchId("10000"); Scanner sc = new Scanner(System.in);
System.out.println(bo); String str = sc.nextLine();
for (int i = 0; i <= 4; i++) {
boolean bo = employee[i].isMatchId(str);
if (bo == true) {
System.out.println(employee[i]);
break;
}
if (bo == false && i == 4) {
System.out.println("該当する社員が見つかりませんでした");
} }
} }
}
}