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() + "件"); + } }