2日目 段階8 小澤

This commit is contained in:
2026-09-15 16:37:48 +09:00
parent 0366ab5ac7
commit cbbfae71fb
2 changed files with 16 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ public class EmployeeData {
return empCount; return empCount;
} }
//getNmEmployee.strip();
public EmployeeData() { public EmployeeData() {
empCount++; empCount++;
@@ -28,6 +30,17 @@ public class EmployeeData {
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password,
String idDepartment) { String idDepartment) {
nmEmployee=nmEmployee.strip();
int nmNum = nmEmployee.length();
if(nmNum==0) {
System.out.println("社員名が空のため設定できませんでした");
}
if(nmNum>0){
this.setIdEmployee(idEmployee); this.setIdEmployee(idEmployee);
this.setNmEmployee(nmEmployee); this.setNmEmployee(nmEmployee);
this.setKnEmployee(knEmployee); this.setKnEmployee(knEmployee);
@@ -36,12 +49,14 @@ public class EmployeeData {
this.setIdDepartment(idDepartment); this.setIdDepartment(idDepartment);
empCount++; empCount++;
} }
}
public String getIdEmployee() { public String getIdEmployee() {
return this.idEmployee; return this.idEmployee;
} }
public void setIdEmployee(String idEmployee) { public void setIdEmployee(String idEmployee) {
this.idEmployee = idEmployee; this.idEmployee = idEmployee;
} }

View File

@@ -2,7 +2,7 @@
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
EmployeeData[] employee = new EmployeeData[5]; 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[1] = new EmployeeData();
employee[2] = new EmployeeData(); employee[2] = new EmployeeData();
employee[3] = new EmployeeData(); employee[3] = new EmployeeData();