From 5358280624bc9db49662914cc6654a08886383ed Mon Sep 17 00:00:00 2001 From: t-eguchi <26-t-eguchi-tmn@it-college.co.jp> Date: Thu, 17 Sep 2026 16:40:22 +0900 Subject: [PATCH] =?UTF-8?q?3=E6=97=A5=E7=9B=AE=E3=81=AE9=E6=AE=B5=E9=9A=8E?= =?UTF-8?q?=E7=9B=AE=E7=B5=82=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- em-oop/src/Main.java | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index 99091bf..0739c03 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -23,20 +23,42 @@ public class Main { allData[9] = new DepartmentData("14", "教育事業部"); allData[10] = new DepartmentData("15", "営業企画部"); - // int count = 0; - // int countt = 0; + String targetDeptId = ""; + + for (int i = 0; i < allData.length; i++) { + + if (allData[i] instanceof DepartmentData) { + DepartmentData dept = (DepartmentData) allData[i]; + + if (dept.getNmDepartment().equals("システム開発事業部")) { + targetDeptId = dept.getIdDepartment(); + break; + } + } + } + for (int i = 0; i < allData.length; i++) { if (allData[i] instanceof EmployeeData) { - // count++; EmployeeData emp = (EmployeeData) allData[i]; - - System.out.println(emp.getMailAddress()); - + if (emp.getIdDepartment().equals(targetDeptId)) { + System.out.println(emp.getNmEmployee() + "\t" + emp.getMailAddress()); + } } - // else if (allData[i] instanceof DepartmentData) { - // countt++; - // } } + + // int count = 0; + // int countt = 0; + // for (int i = 0; i < allData.length; i++) { + // if (allData[i] instanceof EmployeeData) { + // // count++; + // EmployeeData emp = (EmployeeData) allData[i]; + // + // System.out.println(emp.getMailAddress()); + + // else if (allData[i] instanceof DepartmentData) { + // countt++; + // } + // System.out.println("社員のデータ:" + count + "件"); // System.out.println("部署のデータ:" + countt + "件");