From 6468a372ceef3ac1bf80d4d93d4fcb9d158e3eca Mon Sep 17 00:00:00 2001 From: t-eguchi <26-t-eguchi-tmn@it-college.co.jp> Date: Tue, 15 Sep 2026 16:43:23 +0900 Subject: [PATCH] =?UTF-8?q?=EF=BC=97=E6=AE=B5=E9=9A=8E=E7=9B=AE=E7=B5=82?= =?UTF-8?q?=E3=82=8F=E3=82=8A=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- em-oop/src/EmployeeData.java | 17 ++++++++++++++++- em-oop/src/Main.java | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/em-oop/src/EmployeeData.java b/em-oop/src/EmployeeData.java index bcb40d4..6599e38 100644 --- a/em-oop/src/EmployeeData.java +++ b/em-oop/src/EmployeeData.java @@ -7,8 +7,20 @@ public class EmployeeData { private String password; private String idDepartment; - public EmployeeData() { + private static int empCount = 0; + static int getempCount() { + return empCount; + + } + + public EmployeeData() { + empCount++; + + } + + static int getEmpCount() { + return empCount; } public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, @@ -19,6 +31,8 @@ public class EmployeeData { this.setMailAddress(mailAddress); this.setPassword(password); this.setIdDepartment(idDepartment); + empCount++; + } public String getIdEmployee() { @@ -71,6 +85,7 @@ public class EmployeeData { @Override public String toString() { + return (this.getIdEmployee() + "\t" + this.getNmEmployee() + "\t" + this.getKnEmployee() + "\t" + this.getMailAddress() + "\t" + this.getPassword() + "\t" + this.getIdDepartment()); diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java index c5f3560..f62c5b6 100644 --- a/em-oop/src/Main.java +++ b/em-oop/src/Main.java @@ -15,6 +15,8 @@ public class Main { } + System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件"); + } }