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

113 lines
2.6 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;
//ゲッターとセッター
public String getIdEmployee() {
return idEmployee;
}
public void setIdEmployee(String idEmployee) {
if(idEmployee == null || idEmployee.strip().isEmpty()) {
System.out.println("社員IDが空のため設定できませんでした");
}else {
this.idEmployee = idEmployee;
}
}
public String getNmEmployee() {
return nmEmployee;
}
public void setNmEmployee(String nmEmployee) {
if(nmEmployee == null || nmEmployee.strip().isEmpty()) {
System.out.println("社員名が空のため設定できませんでした");
}else {
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;
}
private static int empCount = 0;
//引数なしコンストラクタ
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.getIdEmployee() + "\t" + this.getNmEmployee() + "\t" + this.getKnEmployee() + "\t" +
this.getMailAddress() + "\t" + this.getPassword() + "\t" + this.getIdDepartment());
}
public boolean isMatchId(String id) {
return this.idEmployee.equals(id);
}
static int getEmpCount() {
return empCount;
}
@Override
public String toCSV() {
return (this.getIdEmployee() + "," + this.getNmEmployee() + "," + this.getKnEmployee() + "," +
this.getMailAddress() + "," + this.getPassword() + "," + this.getIdDepartment());
}
public String getPrimaryKeyValue() {
return this.idEmployee;
}
}