Day1、8段回目完了
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
public class EmployeeData extends BaseData {
|
public class EmployeeData extends BaseData {
|
||||||
//フィールド宣言
|
//フィールド宣言
|
||||||
private String idEmployee;//社員ID
|
private String idEmployee;//社員ID
|
||||||
@@ -57,14 +56,14 @@ public class EmployeeData extends BaseData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//メソッド追加
|
//メソッド追加
|
||||||
// void showInfo() {
|
void showInfo() {
|
||||||
// System.out.println(getIdEmployee());
|
System.out.println(getIdEmployee());
|
||||||
// System.out.println(getNmEmployee());
|
System.out.println(getNmEmployee());
|
||||||
// System.out.println(getKnEmployee);
|
System.out.println(getKnEmployee());
|
||||||
// System.out.println(getMailAddress());
|
System.out.println(getMailAddress());
|
||||||
// System.out.println(getPassword());
|
System.out.println(getPassword());
|
||||||
// System.out.println(getIdDepartment());
|
System.out.println(getIdDepartment());
|
||||||
// }
|
}
|
||||||
|
|
||||||
//上記メソッドの書き換え
|
//上記メソッドの書き換え
|
||||||
@Override
|
@Override
|
||||||
@@ -101,9 +100,10 @@ public class EmployeeData extends BaseData {
|
|||||||
return this.idEmployee;
|
return this.idEmployee;
|
||||||
}
|
}
|
||||||
|
|
||||||
//メソッド追加
|
//メソッド追加、7段目
|
||||||
boolean isMatchID(String id) {
|
public boolean isMatchID(String id) {
|
||||||
return idEmployee.equals(id);
|
return idEmployee.equals(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
@@ -17,13 +18,29 @@ public class Main {
|
|||||||
//5段階目記載の処理呼び出し
|
//5段階目記載の処理呼び出し
|
||||||
//employee.showInfo();
|
//employee.showInfo();
|
||||||
|
|
||||||
//for文
|
//Day1、8段階目検索
|
||||||
for (int i = 0; i < employees.length; i++) {
|
Scanner sc = new Scanner(System.in);//インスタンス化
|
||||||
//System.out.println(employees[i]);
|
System.out.println("検索したい社員IDを入力してください");
|
||||||
System.out.println(employees[i].toCSV());
|
String id = sc.next();
|
||||||
System.out.println(employees[i].getPrimaryKeyValue());
|
//boolean変数作成
|
||||||
//employees[i].showInfo();を上記に書き換え
|
boolean result = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < employees.length; i++) {
|
||||||
|
if (employees[i].isMatchID(id)) {
|
||||||
|
result = true;
|
||||||
|
employees[i].showInfo();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result == false) {
|
||||||
|
System.out.println("該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//for文
|
||||||
|
//for (int i = 0; i < employees.length; i++) {
|
||||||
|
//System.out.println(employees[i]);
|
||||||
|
//System.out.println(employees[i].toCSV());
|
||||||
|
//System.out.println(employees[i].getPrimaryKeyValue());
|
||||||
|
//employees[i].showInfo();を上記に書き換え
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user