emopで検索、登録、更新、削除の追加をしました。
This commit is contained in:
@@ -1,97 +1,184 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BaseDate[] employee = new BaseDate[5];
|
||||
ArrayList<EmployeeData> list = new ArrayList<>();
|
||||
list.add(new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10"));
|
||||
list.add(new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "11"));
|
||||
list.add(new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "12"));
|
||||
list.add(new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "13"));
|
||||
list.add(new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "14"));
|
||||
// list.add("10 役員");
|
||||
// list.add("11 人事・総務部");
|
||||
// list.add("12 経理部");
|
||||
// list.add("13 システム開発事業部");
|
||||
// list.add("14 教育事業部");
|
||||
// list.add("15 営業企画部");
|
||||
|
||||
employee[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
||||
employee[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "11");
|
||||
employee[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "12");
|
||||
employee[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "13");
|
||||
employee[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "14");
|
||||
|
||||
DepartmentDate dept1 = new DepartmentDate();
|
||||
dept1.setIdDepartment("10");
|
||||
dept1.setNmDepartment("役員");
|
||||
DepartmentDate dept2 = new DepartmentDate();
|
||||
dept2.setIdDepartment("11");
|
||||
dept2.setNmDepartment("人事・総務部");
|
||||
DepartmentDate dept3 = new DepartmentDate();
|
||||
dept3.setIdDepartment("12");
|
||||
dept3.setNmDepartment("経理部");
|
||||
DepartmentDate dept4 = new DepartmentDate();
|
||||
dept4.setIdDepartment("13");
|
||||
dept4.setNmDepartment("システム開発事業部");
|
||||
DepartmentDate dept5 = new DepartmentDate();
|
||||
dept5.setIdDepartment("14");
|
||||
dept5.setNmDepartment("教育事業部");
|
||||
DepartmentDate dept6 = new DepartmentDate();
|
||||
dept6.setIdDepartment("15");
|
||||
dept6.setNmDepartment("営業企画部");
|
||||
BaseDate[] alldate = new BaseDate[11];
|
||||
alldate[0] = employee[0];
|
||||
alldate[1] = employee[1];
|
||||
alldate[2] = employee[2];
|
||||
alldate[3] = employee[3];
|
||||
alldate[4] = employee[4];
|
||||
alldate[5] = dept1;
|
||||
alldate[6] = dept2;
|
||||
alldate[7] = dept3;
|
||||
alldate[8] = dept4;
|
||||
alldate[9] = dept5;
|
||||
alldate[10] = dept6;
|
||||
|
||||
// int num1 = 0;
|
||||
// int num2 = 0;
|
||||
// for (int i = 0; i <= 10; i++) {
|
||||
// if (alldate[i] instanceof EmployeeData) {
|
||||
// num1++;
|
||||
// EmployeeData emp = (EmployeeData) alldate[i];
|
||||
// System.out.println(emp.getMailAddress());
|
||||
// } else {
|
||||
// num2++;
|
||||
// // System.out.println(alldate[i]);
|
||||
// }
|
||||
// System.out.println("社員データ:" + num1 + "件");
|
||||
// System.out.println("部署データ" + num2 + "件");
|
||||
|
||||
// int i=EmployeeData.getEmpCount();
|
||||
// System.out.println("現在の社員データ件数;"+ i + "件");
|
||||
String id = ("");
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
if (alldate[i] instanceof DepartmentDate) {
|
||||
DepartmentDate dep = (DepartmentDate) alldate[i];
|
||||
if (dep.getNmDepartment().equals("システム開発事業部")) {
|
||||
id = dep.getIdDepartment();
|
||||
break;
|
||||
String str1 = (" ");
|
||||
while (!str1.equals("0")) {
|
||||
System.out.println("1:検索 2:登録 3:更新: 4:削除 0:終了");
|
||||
Scanner sc1 = new Scanner(System.in);
|
||||
str1 = sc1.nextLine();
|
||||
System.out.println(str1);
|
||||
if (str1.equals("1")) {
|
||||
System.out.println("1:全検索 2:条件検索 それ以外:戻る");
|
||||
Scanner sc2 = new Scanner(System.in);
|
||||
String str2 = sc2.nextLine();
|
||||
System.out.println(str2);
|
||||
if (str2.equals("1")) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
System.out.println(list.get(i));
|
||||
}
|
||||
} else if (str2.equals("2")) {
|
||||
System.out.println("検索したい社員IDを入力してください");
|
||||
Scanner sc3 = new Scanner(System.in);
|
||||
String str3 = sc3.nextLine();
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
if (list.get(j).getIdEmployee().equals(str3)) {
|
||||
System.out.println(list.get(j));
|
||||
break;
|
||||
} else if (!list.get(j).getIdEmployee().equals(str3) && j == list.size()) {
|
||||
System.out.println("入力された値で情報が見つかりませんでした");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (alldate[i] instanceof EmployeeData) {
|
||||
EmployeeData emp = (EmployeeData) alldate[i];
|
||||
if (emp.getIdDepartment().equals(id)) {
|
||||
System.out.println(emp.getNmEmployee() + " " + emp.getMailAddress());
|
||||
} else if (str1.equals("2")) {
|
||||
System.out.println("社員IDを入力してください");
|
||||
Scanner sc4 = new Scanner(System.in);
|
||||
String str4 = sc4.nextLine();
|
||||
System.out.println(str4);
|
||||
System.out.println("社員名を入力してください");
|
||||
Scanner sc5 = new Scanner(System.in);
|
||||
String str5 = sc5.nextLine();
|
||||
System.out.println(str5);
|
||||
System.out.println("フリガナを入力してください");
|
||||
Scanner sc6 = new Scanner(System.in);
|
||||
String str6 = sc6.nextLine();
|
||||
System.out.println(str6);
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
Scanner sc7 = new Scanner(System.in);
|
||||
String str7 = sc7.nextLine();
|
||||
System.out.println(str7);
|
||||
System.out.println("パスワードを入力してください");
|
||||
Scanner sc8 = new Scanner(System.in);
|
||||
String str8 = sc8.nextLine();
|
||||
System.out.println(str8);
|
||||
System.out.println("部署IDを入力してください");
|
||||
Scanner sc9 = new Scanner(System.in);
|
||||
String str9 = sc9.nextLine();
|
||||
System.out.println(str9);
|
||||
System.out.println("登録が完了しました");
|
||||
list.add(new EmployeeData(str4, str5, str6, str7, str8, str9));
|
||||
|
||||
} else if (str1.equals("3")) {
|
||||
System.out.println("社員IDを入力してください");
|
||||
Scanner sc4 = new Scanner(System.in);
|
||||
String str4 = sc4.nextLine();
|
||||
for (int k = 0; k < list.size(); k++) {
|
||||
if (list.get(k).getIdEmployee().equals(str4)) {
|
||||
System.out.println(str4);
|
||||
System.out.println("社員名を入力してください");
|
||||
Scanner sc5 = new Scanner(System.in);
|
||||
String str5 = sc5.nextLine();
|
||||
System.out.println(str5);
|
||||
System.out.println("フリガナを入力してください");
|
||||
Scanner sc6 = new Scanner(System.in);
|
||||
String str6 = sc6.nextLine();
|
||||
System.out.println(str6);
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
Scanner sc7 = new Scanner(System.in);
|
||||
String str7 = sc7.nextLine();
|
||||
System.out.println(str7);
|
||||
System.out.println("パスワードを入力してください");
|
||||
Scanner sc8 = new Scanner(System.in);
|
||||
String str8 = sc8.nextLine();
|
||||
System.out.println(str8);
|
||||
System.out.println("部署IDを入力してください");
|
||||
Scanner sc9 = new Scanner(System.in);
|
||||
String str9 = sc9.nextLine();
|
||||
System.out.println(str9);
|
||||
System.out.println("更新が完了しました");
|
||||
list.set(k, new EmployeeData(str4, str5, str6, str7, str8, str9));
|
||||
break;
|
||||
} else if (!list.get(k).getIdEmployee().equals(str4) && k == list.size()) {
|
||||
System.out.println("入力された値で情報が見つかりませんでした");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println(employee[0].toCSV());
|
||||
System.out.println(employee[0].getPrimaryKeyValue());
|
||||
String str = "";
|
||||
while (!str.equals("0")) {
|
||||
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
str = sc.nextLine();
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
if (employee[i].getPrimaryKeyValue().equals(str)) {
|
||||
System.out.println(employee[i]);
|
||||
break;
|
||||
} else if (!employee[i].getPrimaryKeyValue().equals(str) && i == 4 && !str.equals("0")) {
|
||||
System.out.println("該当する社員が見つかりませんでした");
|
||||
} else if (str1.equals("4")) {
|
||||
System.out.println("削除するIDを入力してください");
|
||||
Scanner sc4 = new Scanner(System.in);
|
||||
String str4 = sc4.nextLine();
|
||||
for (int l = 0; l < list.size(); l++) {
|
||||
if (list.get(l).getIdEmployee().equals(str4)) {
|
||||
System.out.println("指定されたIDの情報を削除します? y/Y");
|
||||
System.out.println("y/Y以外の入力であればキャンセル");
|
||||
Scanner sc5 = new Scanner(System.in);
|
||||
String str5 = sc5.nextLine();
|
||||
System.out.println(str5);
|
||||
if (str5.equals("y") || str5.equals("Y")) {
|
||||
list.remove(l);
|
||||
System.out.println("削除されました");
|
||||
break;
|
||||
} else {
|
||||
System.out.println("入力された値で情報が見つかりませんでした");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("システムを終了します");
|
||||
// num1 = 0;
|
||||
// int num2 = 0;
|
||||
// for (int i = 0; i <= 10; i++) {
|
||||
// if (alldate[i] instanceof EmployeeData) {
|
||||
// num1++;
|
||||
// EmployeeData emp = (EmployeeData) alldate[i];
|
||||
// System.out.println(emp.getMailAddress());
|
||||
// } else {
|
||||
// num2++;
|
||||
// System.out.println(alldate[i]);
|
||||
// }
|
||||
// }
|
||||
// System.out.println("社員データ:" + num1 + "件");
|
||||
// System.out.println("部署データ" + num2 + "件");
|
||||
// int j = EmployeeData.getEmpCount();
|
||||
// System.out.println("現在の社員データ件数;" + j + "件");
|
||||
// String id = ("");
|
||||
// for (int k = 0; k <= 10; k++) {
|
||||
// if (alldate[k] instanceof DepartmentDate) {
|
||||
// DepartmentDate dep = (DepartmentDate) alldate[k];
|
||||
// if (dep.getNmDepartment().equals("システム開発事業部")) {
|
||||
// id = dep.getIdDepartment();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int l = 0; l < 10; l++) {
|
||||
// if (alldate[l] instanceof EmployeeData) {
|
||||
// EmployeeData emp = (EmployeeData) alldate[l];
|
||||
// if (emp.getIdDepartment().equals(id)) {
|
||||
// System.out.println(emp.getNmEmployee() + " " + emp.getMailAddress());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// System.out.println(employee[0].toCSV());
|
||||
// System.out.println(employee[0].getPrimaryKeyValue());
|
||||
// String str = "";
|
||||
// while (!str.equals("0")) {
|
||||
// System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||
// Scanner sc3 = new Scanner(System.in);
|
||||
// str = sc.nextLine();
|
||||
// for (int m = 0; m <= 4; m++) {
|
||||
// if (employee[m].getPrimaryKeyValue().equals(str)) {
|
||||
// System.out.println(employee[m]);
|
||||
// break;
|
||||
// } else if (!employee[m].getPrimaryKeyValue().equals(str) && m == 4 && !str.equals("0")) {
|
||||
// System.out.println("該当する社員が見つかりませんでした");
|
||||
// }
|
||||
// }
|
||||
// System.out.println("システムを終了します");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user