From e0c36acb0d2ebfb58fd58778827a1f8e5244ae8f Mon Sep 17 00:00:00 2001 From: m_ozawa <26-m-ozawa-swnet@it-college.co.jp> Date: Tue, 15 Sep 2026 15:44:07 +0900 Subject: [PATCH] =?UTF-8?q?=EF=BC=92=E6=97=A5=E7=9B=AE=E3=80=80=E6=AE=B5?= =?UTF-8?q?=E9=9A=8E=EF=BC=96=E3=80=80=E5=B0=8F=E6=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- em-oop/src/EmployeeData.java | 29 +++++++++++++++++++++-------- em-oop/src/Main.java | 17 +++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/em-oop/src/EmployeeData.java b/em-oop/src/EmployeeData.java index 2986805..555f9e9 100644 --- a/em-oop/src/EmployeeData.java +++ b/em-oop/src/EmployeeData.java @@ -7,9 +7,24 @@ public class EmployeeData { private String password; private String idDepartment; - public void showInfo() { - System.out.println(getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress() - + "\t" + getPassword() + "\t" + getIdDepartment()); + @Override + public String toString() { + return getIdEmployee() + "\t" + getNmEmployee() + " " + getKnEmployee() + "\t" + getMailAddress() + + "\t" + getPassword() + "\t" + getIdDepartment(); + } + + public EmployeeData() { + + } + + public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, + String idDepartment) { + this.setIdEmployee(idEmployee); + this.setNmEmployee(nmEmployee); + this.setKnEmployee(knEmployee); + this.setMailAddress(mailAddress); + this.setPassword(password); + this.setIdDepartment(idDepartment); } public String getIdEmployee() { @@ -35,13 +50,13 @@ public class EmployeeData { public void setKnEmployee(String knEmployee) { this.knEmployee = knEmployee; } - + public String getMailAddress() { return this.mailAddress; } - + public void setMailAddress(String mailAddress) { - this.mailAddress=mailAddress; + this.mailAddress = mailAddress; } public String getPassword() { @@ -59,7 +74,5 @@ public class EmployeeData { public void setIdDepartment(String idDepartment) { this.idDepartment = idDepartment; } - - } diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index 91f0414..0a8bc3d 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -2,20 +2,21 @@ public class Main { public static void main(String[] args) { EmployeeData[] employee = new EmployeeData[5]; - employee[0] = new EmployeeData(); + employee[0] = new EmployeeData("10000","山田龍也","ヤマダタツヤ","yamada@hoge.jp","aaa","10"); employee[1] = new EmployeeData(); employee[2] = new EmployeeData(); employee[3] = new EmployeeData(); employee[4] = new EmployeeData(); - employee[0].setIdEmployee("10000"); - employee[0].setNmEmployee("山田龍也"); - employee[0].setKnEmployee("ヤマダタツヤ"); - employee[0].setMailAddress("yamada@hoge.jp"); - employee[0].setPassword("aaa"); - employee[0].setIdDepartment("10"); +// employee[0].setIdEmployee("10000"); +// employee[0].setNmEmployee("山田龍也"); +// employee[0].setKnEmployee("ヤマダタツヤ"); +// employee[0].setMailAddress("yamada@hoge.jp"); +// employee[0].setPassword("aaa"); +// employee[0].setIdDepartment("10"); +// employee[1].setIdEmployee("10001"); employee[1].setNmEmployee("高橋準"); employee[1].setKnEmployee("タカハシジュン"); @@ -46,7 +47,7 @@ public class Main { // for(int i=0;i<5;i++) { - employee[i].showInfo(); + System.out.println(employee[i]); }