Files
java-cui-em-oop/em-oop/src/EmployeeData.java

113 lines
2.4 KiB
Java

public class EmployeeData extends BaseData {
private String idEmployee;
private String nmEmployee;
private String knEmployee;
private String mailAddress;
private String password;
private String idDepartment;
private static int empCount = 0;
static final String COMPANY_NAME = "Rhizome";
//コンストラクタ
public EmployeeData() {
empCount++;
}
//引数ありコンストラクタ
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);
empCount++;
}
@Override
public String toString() {
return this.idEmployee + "\t" + this.nmEmployee
+ "\t" + this.knEmployee + "\t" + this.mailAddress
+ "\t" + this.password + "\t" + this.idDepartment;
}
public String getIdEmployee() {
return idEmployee;
}
public void setIdEmployee(String idEmployee) {
if (!check(idEmployee, "社員ID"))
return;
this.idEmployee = idEmployee;
}
public String getNmEmployee() {
return nmEmployee;
}
public void setNmEmployee(String nmEmployee) {
if (!check(nmEmployee, "社員名"))
return;
this.nmEmployee = nmEmployee;
}
public String getKnEmployee() {
return knEmployee;
}
public void setKnEmployee(String knEmployee) {
this.knEmployee = knEmployee;
}
public String getMailAddress() {
return mailAddress;
}
public void setMailAddress(String mailAddress) {
this.mailAddress = mailAddress;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getIdDepartment() {
return idDepartment;
}
public void setIdDepartment(String idDepartment) {
this.idDepartment = idDepartment;
}
public static int getEmpCount() {
return empCount;
}
private boolean check(String str, String stringName) {
if (str == null || str.strip().length() == 0) {
System.out.println(stringName + "が空のため設定できませんでした");
return false;
}
return true;
}
@Override
public String toCSV() {
return getIdEmployee() + "," + getNmEmployee() + "," + getKnEmployee() + ","
+ getMailAddress() + "," + getPassword() + "," + getIdDepartment();
}
@Override
public String getPrimaryKeyValue() {
return this.idEmployee;
}
}