4段階目(BaseDataを作り、EmployeeDataに継承させよう)
This commit is contained in:
8
em-oop/src/BaseData.java
Normal file
8
em-oop/src/BaseData.java
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
public abstract class BaseData {
|
||||
public abstract String toString();
|
||||
|
||||
public abstract String toCSV();
|
||||
|
||||
public abstract String getPrimaryKeyValue();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
public class EmployeeData {
|
||||
public class EmployeeData extends BaseData {
|
||||
private String idEmployee;
|
||||
private String nmEmployee;
|
||||
private String knEmployee;
|
||||
@@ -112,4 +112,15 @@ public class EmployeeData {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCSV() {
|
||||
return getIdEmployee() + "," + getNmEmployee() + "," + getKnEmployee() + ","
|
||||
+ getMailAddress() + "," + getPassword() + "," + getIdDepartment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryKeyValue() {
|
||||
return this.idEmployee;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("会社名:" + EmployeeData.COMPANY_NAME);
|
||||
|
||||
// EmployeeData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ",
|
||||
// "yamada@hoge.jp", "aaa", "10");
|
||||
// System.out.println(employee);
|
||||
//
|
||||
// System.out.println();
|
||||
EmployeeData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ",
|
||||
"yamada@hoge.jp", "aaa", "10");
|
||||
System.out.println(employee.toCSV());
|
||||
System.out.println(employee.getPrimaryKeyValue());
|
||||
|
||||
System.out.println();
|
||||
|
||||
EmployeeData[] employees = new EmployeeData[5];
|
||||
for (int i = 0; i < employees.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user