diff --git a/em-oop/src/EmployeeData.java b/em-oop/src/EmployeeData.java index 9da6e23..dbea8a8 100644 --- a/em-oop/src/EmployeeData.java +++ b/em-oop/src/EmployeeData.java @@ -10,6 +10,11 @@ public class EmployeeData extends BaceData { static final String COMPANY_NAME = "Rhizome"; + public void showInfo() { + System.out.println(this.idEmployee + "\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + this.mailAddress + + "\t" + this.mailAddress + "\t" + this.password + "\t" + this.idDepartment); + } + @Override public String toString() { return getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress() @@ -27,7 +32,7 @@ public class EmployeeData extends BaceData { return getIdEmployee(); } - + public boolean isMatchId(String id) { return idEmployee.equals(id); } diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index b3486d6..b72779a 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -1,3 +1,4 @@ +import java.util.Scanner; public class Main { public static void main(String[] args) { @@ -39,25 +40,35 @@ public class Main { // System.out.println(employees[1].toCSV()); // System.out.println(employees[1].getPrimaryKeyValue()); - System.out.println("10002を検索します"); + Scanner sc = new Scanner(System.in); + + System.out.println("検索したい社員IDを入力してください"); + String id = sc.nextLine(); boolean result = false; for (int i = 0; i < employees.length; i++) { - if (employees[i].isMatchId("10002")) { + if (employees[i].isMatchId(id)) { result = true; + employees[i].showInfo(); break; } + } + + if(result==false) { + System.out.println("該当する社員が見つかりませんでした"); } - System.out.println(result); - System.out.println("99999を検索します"); - result=false; - for(int i=0;i