From bd691238e72d3684934b0038bce9d0d23e8da253 Mon Sep 17 00:00:00 2001 From: m_ozawa <26-m-ozawa-swnet@it-college.co.jp> Date: Wed, 16 Sep 2026 14:56:47 +0900 Subject: [PATCH] =?UTF-8?q?=EF=BC=92=E6=97=A5=E7=9B=AE=E3=80=80=E3=82=B3?= =?UTF-8?q?=E3=83=9F=E3=83=83=E3=83=88=E3=81=97=E3=81=A6=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- em-oop/src/EmployeeData.java | 49 ++++++++++++++++++------------------ em-oop/src/Main.java | 5 +++- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/em-oop/src/EmployeeData.java b/em-oop/src/EmployeeData.java index 969934d..1aceb8c 100644 --- a/em-oop/src/EmployeeData.java +++ b/em-oop/src/EmployeeData.java @@ -7,20 +7,19 @@ public class EmployeeData { private String password; private String idDepartment; private static int empCount = 0; - + static final String COMPANY_NAME = "Rhizome"; - @Override public String toString() { return getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress() + "\t" + getPassword() + "\t" + getIdDepartment(); } - + static int getEmpCount() { return empCount; } - + //getNmEmployee.strip(); public EmployeeData() { @@ -30,24 +29,30 @@ public class EmployeeData { public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, String idDepartment) { - - nmEmployee=nmEmployee.strip(); + + nmEmployee = nmEmployee.strip(); int nmNum = nmEmployee.length(); - - if(nmNum==0) { + + idEmployee = idEmployee.strip(); + int idNum = idEmployee.length(); + + if (nmNum == 0) { System.out.println("社員名が空のため設定できませんでした"); - + } - if(nmNum>0){ - - - this.setIdEmployee(idEmployee); - this.setNmEmployee(nmEmployee); - this.setKnEmployee(knEmployee); - this.setMailAddress(mailAddress); - this.setPassword(password); - this.setIdDepartment(idDepartment); - empCount++; + if (idNum == 0) { + System.out.println("社員IDが空のため設定できませんでした"); + } + if (nmNum > 0 && idNum > 0) { + + this.setIdEmployee(idEmployee); + this.setNmEmployee(nmEmployee); + this.setKnEmployee(knEmployee); + this.setMailAddress(mailAddress); + this.setPassword(password); + this.setIdDepartment(idDepartment); + empCount++; + } } @@ -56,7 +61,7 @@ public class EmployeeData { } public void setIdEmployee(String idEmployee) { - + this.idEmployee = idEmployee; } @@ -100,8 +105,4 @@ public class EmployeeData { this.idDepartment = idDepartment; } - - - - } diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index 4d9c83f..0082d36 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -2,7 +2,7 @@ public class Main { public static void main(String[] args) { EmployeeData[] employee = new EmployeeData[5]; - employee[0] = new EmployeeData("10000"," ","ヤマダタツヤ","yamada@hoge.jp","aaa","10"); + employee[0] = new EmployeeData("10000","","ヤマダタツヤ","yamada@hoge.jp","aaa","10"); employee[1] = new EmployeeData(); employee[2] = new EmployeeData(); employee[3] = new EmployeeData(); @@ -48,6 +48,9 @@ public class Main { for(int i=0;i<5;i++) { + if(employee[i].getNmEmployee()==null) { + continue; + } System.out.println(employee[i]); }