9段階目(何度でも検索できるようにしよう)

This commit is contained in:
s-sakiyama
2026-09-15 16:06:53 +09:00
parent 1c4b834578
commit 8fbfa99047

View File

@@ -91,18 +91,30 @@ public class Main {
System.out.println(); System.out.println();
System.out.println("検索したい社員IDを入力してください");
System.out.println("(5桁の数字)");
System.out.print(">>>>");
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
System.out.print(">>>>");
String findId = scanner.nextLine(); String findId = scanner.nextLine();
if (findId.equals("0")) {
System.out.println("システムを終了します");
return;
}
boolean matchFlag = false;
for (EmployeeData e : employees) { for (EmployeeData e : employees) {
if (e.isMatchId(findId)) { if (e.isMatchId(findId)) {
System.out.println(e); System.out.println(e);
return; matchFlag = true;
break;
} }
} }
if (!matchFlag) {
System.out.println("該当する社員が見つかりませんでした"); System.out.println("該当する社員が見つかりませんでした");
}
System.out.println();
}
} }