Day1、8段回目完了

This commit is contained in:
m-endo
2026-09-24 13:30:29 +09:00
parent b55cbe7128
commit 1777d45dd1
2 changed files with 35 additions and 18 deletions

View File

@@ -1,4 +1,3 @@
public class EmployeeData extends BaseData {
//フィールド宣言
private String idEmployee;//社員ID
@@ -57,14 +56,14 @@ public class EmployeeData extends BaseData {
}
//メソッド追加
// void showInfo() {
// System.out.println(getIdEmployee());
// System.out.println(getNmEmployee());
// System.out.println(getKnEmployee);
// System.out.println(getMailAddress());
// System.out.println(getPassword());
// System.out.println(getIdDepartment());
// }
void showInfo() {
System.out.println(getIdEmployee());
System.out.println(getNmEmployee());
System.out.println(getKnEmployee());
System.out.println(getMailAddress());
System.out.println(getPassword());
System.out.println(getIdDepartment());
}
//上記メソッドの書き換え
@Override
@@ -101,9 +100,10 @@ public class EmployeeData extends BaseData {
return this.idEmployee;
}
//メソッド追加
boolean isMatchID(String id) {
//メソッド追加、7段目
public boolean isMatchID(String id) {
return idEmployee.equals(id);
}
}

View File

@@ -1,3 +1,4 @@
import java.util.Scanner;
public class Main {
@@ -17,13 +18,29 @@ public class Main {
//5段階目記載の処理呼び出し
//employee.showInfo();
//for文
for (int i = 0; i < employees.length; i++) {
//System.out.println(employees[i]);
System.out.println(employees[i].toCSV());
System.out.println(employees[i].getPrimaryKeyValue());
//employees[i].showInfo();を上記に書き換え
//Day1、8段階目検索
Scanner sc = new Scanner(System.in);//インスタンス化
System.out.println("検索したい社員IDを入力してください");
String id = sc.next();
//boolean変数作成
boolean result = false;
for (int i = 0; i < employees.length; i++) {
if (employees[i].isMatchID(id)) {
result = true;
employees[i].showInfo();
break;
}
}
if (result == false) {
System.out.println("該当する社員が見つかりませんでした");
}
}
//for文
//for (int i = 0; i < employees.length; i++) {
//System.out.println(employees[i]);
//System.out.println(employees[i].toCSV());
//System.out.println(employees[i].getPrimaryKeyValue());
//employees[i].showInfo();を上記に書き換え
}