diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index fe0f9c0..2e4646d 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -1,5 +1,3 @@ -import java.util.Scanner; - public class Main { public static void main(String[] args) { BaseData employee = new EmployeeData(); @@ -16,6 +14,7 @@ public class Main { dept.setIdDepartment("10"); dept.setNmDepartment("役員"); allData[5] = dept; + dept = new DepartmentData(); dept.setIdDepartment("11"); dept.setNmDepartment("人事・総務部"); dept = new DepartmentData(); @@ -36,14 +35,39 @@ public class Main { dept.setNmDepartment("営業企画部"); allData[10] = dept; + DepartmentData dep = null; + EmployeeData emp ; + String nmD=null; + + for (int i=0; i < allData.length; i++) { + if (allData[i] instanceof DepartmentData) { + dep = (DepartmentData) allData[i]; + if (dep.getNmDepartment().equals("システム開発事業部")) { + nmD=dep.getIdDepartment(); + } + } + + + } + + + for (int i = 0; i < allData.length; i++) { if (allData[i] instanceof EmployeeData) { - EmployeeData emp = (EmployeeData) allData[i]; - - System.out.println(emp.getMailAddress()); - } + emp = (EmployeeData) allData[i]; + if (emp.getIdDepartment().equals(nmD)) { + System.out.println(emp.getNmEmployee() + "\t" + emp.getMailAddress()); + } + } + // for (int i = 0; i < allData.length; i++) { + // if (allData[i] instanceof EmployeeData) { + // EmployeeData emp = (EmployeeData) allData[i]; + // System.out.println(emp.getMailAddress()); + // } + // } + // int emp=0; // int dep=0; // for(int i=0;i