追加問題まで実装完了済み
This commit is contained in:
6
file/DepartmentData.csv
Normal file
6
file/DepartmentData.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
10,役員
|
||||||
|
11,人事・総務部
|
||||||
|
12,経理部
|
||||||
|
13,システム開発事業部
|
||||||
|
14,教育事業部
|
||||||
|
15,営業企画部
|
||||||
|
6
file/EmployeeData.csv
Normal file
6
file/EmployeeData.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
10000,山田龍也,ヤマダタツヤ,yamada@hoge.jp,aaa,10
|
||||||
|
10001,高橋準,タカハシジュン,jtaka@hoge.jp,bbb,10
|
||||||
|
10002,麻枝史明,マエダフミアキ,fmak@hoge.jp,ccc,11
|
||||||
|
1,1,1,1,1,1
|
||||||
|
3,2,2,2,2,2
|
||||||
|
4,4,4,4,4,4
|
||||||
|
8
src/main/java/BaseData.java
Normal file
8
src/main/java/BaseData.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
public abstract class BaseData {
|
||||||
|
|
||||||
|
public abstract String toString();
|
||||||
|
public abstract String toCSV();
|
||||||
|
public abstract String getPrimaryKeyValue();
|
||||||
|
|
||||||
|
}
|
||||||
49
src/main/java/DepartmentData.java
Normal file
49
src/main/java/DepartmentData.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
public class DepartmentData extends BaseData {
|
||||||
|
|
||||||
|
private String idDepartment;
|
||||||
|
private String nmDepartment;
|
||||||
|
|
||||||
|
public DepartmentData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DepartmentData(String idDepartment,String nmDepartment) {
|
||||||
|
this.setIdDepartment(idDepartment);
|
||||||
|
this.setNmDepartment(nmDepartment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdDepartment() {
|
||||||
|
return idDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdDepartment(String idDepartment) {
|
||||||
|
this.idDepartment = idDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmDepartment() {
|
||||||
|
return nmDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNmDepartment(String nmDepartment) {
|
||||||
|
this.nmDepartment = nmDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getIdDepartment()+"\t"
|
||||||
|
+this.getNmDepartment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toCSV() {
|
||||||
|
return this.getIdDepartment()+","
|
||||||
|
+this.getNmDepartment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryKeyValue() {
|
||||||
|
return this.getIdDepartment();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
public class EmployeeData {
|
public class EmployeeData extends BaseData {
|
||||||
|
|
||||||
static final String COMPANY_NAME = "Rhizome";
|
static final String COMPANY_NAME = "Rhizome";
|
||||||
private static int empCount = 0;
|
private static int empCount = 0;
|
||||||
@@ -93,18 +93,31 @@ public class EmployeeData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
return this.getIdEmployee()+"\t"
|
return this.getIdEmployee()+"\t"
|
||||||
+this.getNmEmployee()+"\t"
|
+this.getNmEmployee()+"\t"
|
||||||
+this.getKnEmployee()+"\t"
|
+this.getKnEmployee()+"\t"
|
||||||
+this.getMailAddress()+"\t"
|
+this.getMailAddress()+"\t"
|
||||||
+this.getPassword()+"\t"
|
+this.getPassword()+"\t"
|
||||||
+this.getIdDepartment();
|
+this.getIdDepartment();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMatchId(String id) {
|
// public boolean isMatchId(String id) {
|
||||||
return id.equals(this.getIdEmployee()) ;
|
// return id.equals(this.getIdEmployee()) ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toCSV() {
|
||||||
|
return this.getIdEmployee()+","
|
||||||
|
+this.getNmEmployee()+","
|
||||||
|
+this.getKnEmployee()+","
|
||||||
|
+this.getMailAddress()+","
|
||||||
|
+this.getPassword()+","
|
||||||
|
+this.getIdDepartment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryKeyValue() {
|
||||||
|
return this.getIdEmployee();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,62 +7,91 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
//====================設定====================
|
//====================設定====================
|
||||||
EmployeeData[] employees = new EmployeeData[5];
|
BaseData[] employees = new BaseData[5];
|
||||||
|
|
||||||
// EmployeeData employee0 = new EmployeeData();
|
BaseData employee1 = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
||||||
// employee0.setIdEmployee(""); // 社員IDが空文字のとき
|
|
||||||
// employee0.setNmEmployee(""); // 社員名が空文字のとき
|
|
||||||
|
|
||||||
EmployeeData employee1 = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
|
||||||
// EmployeeData employee1 = new EmployeeData();
|
|
||||||
// employee1.setIdEmployee("10000");
|
|
||||||
// employee1.setNmEmployee("山田龍也");
|
|
||||||
// employee1.setKnEmployee("ヤマダタツヤ");
|
|
||||||
// employee1.setMailAddress("yamada@hoge.jp");
|
|
||||||
// employee1.setPassword("aaa");
|
|
||||||
// employee1.setIdDepartment("10");
|
|
||||||
employees[1-1] = employee1;
|
employees[1-1] = employee1;
|
||||||
|
BaseData employee2 = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
|
||||||
EmployeeData employee2 = new EmployeeData();
|
|
||||||
employee2.setIdEmployee("10001");
|
|
||||||
employee2.setNmEmployee("高橋準");
|
|
||||||
employee2.setKnEmployee("タカハシジュン");
|
|
||||||
employee2.setMailAddress("jtaka@hoge.jp");
|
|
||||||
employee2.setPassword("bbb");
|
|
||||||
employee2.setIdDepartment("10");
|
|
||||||
employees[2-1] = employee2;
|
employees[2-1] = employee2;
|
||||||
|
BaseData employee3 = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
|
||||||
EmployeeData employee3 = new EmployeeData();
|
|
||||||
employee3.setIdEmployee("10002");
|
|
||||||
employee3.setNmEmployee("麻枝史明");
|
|
||||||
employee3.setKnEmployee("マエダフミアキ");
|
|
||||||
employee3.setMailAddress("fmak@hoge.jp");
|
|
||||||
employee3.setPassword("ccc");
|
|
||||||
employee3.setIdDepartment("11");
|
|
||||||
employees[3-1] = employee3;
|
employees[3-1] = employee3;
|
||||||
|
BaseData employee4 = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
|
||||||
EmployeeData employee4 = new EmployeeData();
|
|
||||||
employee4.setIdEmployee("10003");
|
|
||||||
employee4.setNmEmployee("丸戸章介");
|
|
||||||
employee4.setKnEmployee("マルトショウスケ");
|
|
||||||
employee4.setMailAddress("marusyo@hoge.jp");
|
|
||||||
employee4.setPassword("ddd");
|
|
||||||
employee4.setIdDepartment("12");
|
|
||||||
employees[4-1] = employee4;
|
employees[4-1] = employee4;
|
||||||
|
BaseData employee5 = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "13");
|
||||||
EmployeeData employee5 = new EmployeeData();
|
|
||||||
employee5.setIdEmployee("10004");
|
|
||||||
employee5.setNmEmployee("三宅武");
|
|
||||||
employee5.setKnEmployee("ミヤケタケシ");
|
|
||||||
employee5.setMailAddress("miya@hoge.jp");
|
|
||||||
employee5.setPassword("eee");
|
|
||||||
employee5.setIdDepartment("13");
|
|
||||||
employees[5-1] = employee5;
|
employees[5-1] = employee5;
|
||||||
|
|
||||||
|
BaseData[] allData = new BaseData[11];
|
||||||
|
|
||||||
|
allData[0] = employees[0];
|
||||||
|
allData[1] = employees[1];
|
||||||
|
allData[2] = employees[2];
|
||||||
|
allData[3] = employees[3];
|
||||||
|
allData[4] = employees[4];
|
||||||
|
|
||||||
|
DepartmentData department1 = new DepartmentData();
|
||||||
|
department1.setIdDepartment("10");
|
||||||
|
department1.setNmDepartment("役員");
|
||||||
|
allData[5] = department1;
|
||||||
|
DepartmentData department2 = new DepartmentData();
|
||||||
|
department2.setIdDepartment("11");
|
||||||
|
department2.setNmDepartment("人事");
|
||||||
|
allData[6] = department2;
|
||||||
|
DepartmentData department3 = new DepartmentData();
|
||||||
|
department3.setIdDepartment("12");
|
||||||
|
department3.setNmDepartment("経理部");
|
||||||
|
allData[7] = department3;
|
||||||
|
DepartmentData department4 = new DepartmentData();
|
||||||
|
department4.setIdDepartment("13");
|
||||||
|
department4.setNmDepartment("システム開発事業部");
|
||||||
|
allData[8] = department4;
|
||||||
|
DepartmentData department5 = new DepartmentData();
|
||||||
|
department5.setIdDepartment("14");
|
||||||
|
department5.setNmDepartment("教育事業部");
|
||||||
|
allData[9] = department5;
|
||||||
|
DepartmentData department6 = new DepartmentData();
|
||||||
|
department6.setIdDepartment("15");
|
||||||
|
department6.setNmDepartment("営業企画部");
|
||||||
|
allData[10] = department6;
|
||||||
|
|
||||||
|
// 段階7+8
|
||||||
|
int nEmployeeData = 0;
|
||||||
|
int nDepartmentData = 0;
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
// System.out.println(data);
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
System.out.println(((EmployeeData)data).getMailAddress());
|
||||||
|
nEmployeeData++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( data instanceof DepartmentData ) {
|
||||||
|
nDepartmentData++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("社員データ:"+nEmployeeData+"件");
|
||||||
|
System.out.println("部署データ:"+nDepartmentData+"件");
|
||||||
|
|
||||||
|
// 段階9
|
||||||
|
String ID = "";
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof DepartmentData ) {
|
||||||
|
if ( ((DepartmentData)data).getNmDepartment().equals("システム開発事業部") ) {
|
||||||
|
ID = data.getPrimaryKeyValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
if ( ((EmployeeData)data).getIdDepartment().equals(ID) ) {
|
||||||
|
System.out.println(((EmployeeData)data).getNmEmployee()+" "+((EmployeeData)data).getMailAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================表示====================
|
//====================表示====================
|
||||||
System.out.println(EmployeeData.COMPANY_NAME);
|
System.out.println(EmployeeData.COMPANY_NAME);
|
||||||
for ( EmployeeData employee : employees ) {
|
for ( BaseData employee : employees ) {
|
||||||
System.out.println(employee);
|
System.out.println(employee);
|
||||||
}
|
}
|
||||||
System.out.println("現在の社員データ件数:"+EmployeeData.getEmpCount()+"件");
|
System.out.println("現在の社員データ件数:"+EmployeeData.getEmpCount()+"件");
|
||||||
@@ -81,8 +110,8 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean matchId = false;
|
boolean matchId = false;
|
||||||
for ( EmployeeData employee : employees ) {
|
for ( BaseData employee : employees ) {
|
||||||
if ( employee.isMatchId(id) ) {
|
if ( employee.getPrimaryKeyValue().equals(id) ) {
|
||||||
matchId = true;
|
matchId = true;
|
||||||
System.out.println(employee);;
|
System.out.println(employee);;
|
||||||
}
|
}
|
||||||
|
|||||||
280
src/main/java/MainNew.java
Normal file
280
src/main/java/MainNew.java
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class MainNew {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
// csvファイルからデータを読み込む
|
||||||
|
ArrayList<BaseData> allData = readCSV();
|
||||||
|
|
||||||
|
// 会社情報表示
|
||||||
|
//System.out.println(EmployeeData.COMPANY_NAME);
|
||||||
|
|
||||||
|
|
||||||
|
//====================管理機能====================
|
||||||
|
|
||||||
|
System.out.println("1:検索 2:登録 3:更新 4:削除 0:終了");
|
||||||
|
// 操作項目入力
|
||||||
|
String index = sc.nextLine();
|
||||||
|
|
||||||
|
// 入力1=検索
|
||||||
|
if (index.equals("1")) {
|
||||||
|
System.out.println("1:全検索 2:条件検索 それ以外:戻る");
|
||||||
|
String indexSearch = sc.nextLine();
|
||||||
|
if (indexSearch.equals("1")) {
|
||||||
|
// 全検索
|
||||||
|
displayEmployee(allData);
|
||||||
|
continue;
|
||||||
|
} else if (indexSearch.equals("2")) {
|
||||||
|
// 条件検索
|
||||||
|
searchEmployee(allData,sc);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入力2=登録
|
||||||
|
if (index.equals("2")) {
|
||||||
|
registerEmployee(allData,sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入力3=更新
|
||||||
|
if (index.equals("3")) {
|
||||||
|
updateEmployee(allData,sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入力4=削除
|
||||||
|
if (index.equals("4")) {
|
||||||
|
removeEmployee(allData,sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入力0=終了
|
||||||
|
if ( index.equals("0") ) {
|
||||||
|
System.out.println("システムを終了します");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// csvファイルから情報を読み込む
|
||||||
|
public static ArrayList<BaseData> readCSV() {
|
||||||
|
|
||||||
|
ArrayList<BaseData> allData = new ArrayList<BaseData>();
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 社員情報を読み込む
|
||||||
|
File empFile = new File("/Users/鈴木 皓介/Documents/em-oop/file/EmployeeData.csv");
|
||||||
|
String empline = "";
|
||||||
|
BufferedReader empbr = new BufferedReader(new InputStreamReader(new FileInputStream(empFile),"UTF-8"));
|
||||||
|
while ((empline=empbr.readLine())!=null) {
|
||||||
|
String[] data = empline.split(",",0);
|
||||||
|
BaseData employee = new EmployeeData(data[0],data[1],data[2],data[3],data[4],data[5]);
|
||||||
|
allData.add(employee);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 部署情報を読み込む
|
||||||
|
File depFile = new File("/Users/鈴木 皓介/Documents/em-oop/file/DepartmentData.csv");
|
||||||
|
String depline = "";
|
||||||
|
BufferedReader depbr = new BufferedReader(new InputStreamReader(new FileInputStream(depFile),"UTF-8"));
|
||||||
|
while ((depline=depbr.readLine())!=null) {
|
||||||
|
String[] data = depline.split(",",0);
|
||||||
|
BaseData department = new DepartmentData(data[0],data[1]);
|
||||||
|
allData.add(department);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException err) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
return allData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// csvファイルに社員データを書き込む
|
||||||
|
public static void writeEmployee(ArrayList<BaseData> allData) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 社員情報を書き込む
|
||||||
|
File empFile = new File("/Users/鈴木 皓介/Documents/em-oop/file/EmployeeData.csv");
|
||||||
|
FileWriter empfr = new FileWriter(empFile);
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
empfr.append(data.toCSV()+"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
empfr.close();
|
||||||
|
|
||||||
|
} catch (IOException err) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 全検索(社員情報表示)
|
||||||
|
public static void displayEmployee(ArrayList<BaseData> allData) {
|
||||||
|
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
System.out.println(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 社員ID照合
|
||||||
|
public static boolean matchIdEmployee(ArrayList<BaseData> allData,String id) {
|
||||||
|
|
||||||
|
boolean isMatched = false;
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
if ( data.getPrimaryKeyValue().equals(id) ) {
|
||||||
|
isMatched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isMatched;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ID照合→該当BaseData配列インデックス取得
|
||||||
|
public static int getIndexArray(ArrayList<BaseData> allData,String id) {
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for ( BaseData data : allData ) {
|
||||||
|
if ( data instanceof EmployeeData ) {
|
||||||
|
if ( data.getPrimaryKeyValue().equals(id) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 条件検索
|
||||||
|
public static void searchEmployee(ArrayList<BaseData> allData,Scanner sc) {
|
||||||
|
|
||||||
|
System.out.println("検索したい社員IDを入力してください");
|
||||||
|
String id = sc.nextLine();
|
||||||
|
|
||||||
|
boolean isMatched = matchIdEmployee(allData,id);
|
||||||
|
if (isMatched==false) {
|
||||||
|
System.out.println("入力されたIDに該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
if (isMatched==true) {
|
||||||
|
System.out.println(allData.get(getIndexArray(allData,id)));
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 登録
|
||||||
|
public static void registerEmployee(ArrayList<BaseData> allData,Scanner sc) {
|
||||||
|
|
||||||
|
System.out.println("登録したい社員IDを入力してください");
|
||||||
|
String id = sc.nextLine();
|
||||||
|
|
||||||
|
boolean isMatched = matchIdEmployee(allData,id);
|
||||||
|
if (isMatched==false) {
|
||||||
|
String[] newdata = new String[6];
|
||||||
|
newdata[0] = id;
|
||||||
|
System.out.println("社員名を入力してください");
|
||||||
|
newdata[1] = sc.nextLine();
|
||||||
|
System.out.println("フリガナを入力してください");
|
||||||
|
newdata[2] = sc.nextLine();
|
||||||
|
System.out.println("メールアドレスを入力してください");
|
||||||
|
newdata[3] = sc.nextLine();
|
||||||
|
System.out.println("パスワードを入力してください");
|
||||||
|
newdata[4] = sc.nextLine();
|
||||||
|
System.out.println("部署IDを入力してください");
|
||||||
|
newdata[5] = sc.nextLine();
|
||||||
|
System.out.println("登録が完了しました");
|
||||||
|
allData.add(new EmployeeData(newdata[0],newdata[1],newdata[2],newdata[3],newdata[4],newdata[5]));
|
||||||
|
writeEmployee(allData);
|
||||||
|
}
|
||||||
|
if (isMatched==true) {
|
||||||
|
System.out.println("入力されたIDは既に登録されています");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 更新
|
||||||
|
public static void updateEmployee(ArrayList<BaseData> allData,Scanner sc) {
|
||||||
|
|
||||||
|
System.out.println("更新したい社員IDを入力してください");
|
||||||
|
String id = sc.nextLine();
|
||||||
|
|
||||||
|
boolean isMatched = matchIdEmployee(allData,id);
|
||||||
|
if (isMatched==false) {
|
||||||
|
System.out.println("入力されたIDに該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
if (isMatched==true) {
|
||||||
|
BaseData data = allData.get(getIndexArray(allData,id));
|
||||||
|
System.out.println("社員名を入力してください");
|
||||||
|
((EmployeeData)data).setNmEmployee(sc.nextLine());
|
||||||
|
System.out.println("フリガナを入力してください");
|
||||||
|
((EmployeeData)data).setKnEmployee(sc.nextLine());
|
||||||
|
System.out.println("メールアドレスを入力してください");
|
||||||
|
((EmployeeData)data).setMailAddress(sc.nextLine());
|
||||||
|
System.out.println("パスワードを入力してください");
|
||||||
|
((EmployeeData)data).setPassword(sc.nextLine());
|
||||||
|
System.out.println("部署IDを入力してください");
|
||||||
|
((EmployeeData)data).setIdDepartment(sc.nextLine());
|
||||||
|
System.out.println("更新が完了しました");
|
||||||
|
writeEmployee(allData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 消去
|
||||||
|
public static void removeEmployee(ArrayList<BaseData> allData,Scanner sc) {
|
||||||
|
|
||||||
|
System.out.println("削除したい社員IDを入力してください");
|
||||||
|
String id = sc.nextLine();
|
||||||
|
|
||||||
|
boolean isMatched = matchIdEmployee(allData,id);
|
||||||
|
if (isMatched==false) {
|
||||||
|
System.out.println("入力されたIDに該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
if (isMatched==true) {
|
||||||
|
System.out.println("指定されたIDに該当する社員の情報を削除しますか? Y/y");
|
||||||
|
System.out.println("Y/y以外:キャンセル");
|
||||||
|
String flag = sc.nextLine();
|
||||||
|
if (flag.equals("Y")||flag.equals("y")) {
|
||||||
|
allData.remove(getIndexArray(allData,id));
|
||||||
|
System.out.println("削除が完了しました");
|
||||||
|
writeEmployee(allData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
10000,山田龍也,ヤマダタツヤ,yamada@hoge.jp,aaa,10
|
|
||||||
10001,高橋準,タカハシジュン,jtaka@hoge.jp,bbb,10
|
10001,高橋準,タカハシジュン,jtaka@hoge.jp,bbb,10
|
||||||
10002,麻枝史明,マエダフミアキ,fmak@hoge.jp,ccc,11
|
10002,麻枝史明,マエダフミアキ,fmak@hoge.jp,ccc,11
|
||||||
10003,丸戸章介,マルトショウスケ,marusyo@hoge.jp,ddd,12
|
|
||||||
10004,三宅武,ミヤケタケシ,miya@hoge.jp,eee,13
|
|
||||||
10005,丸井悠,マルイハルカ,haru@hoge.jp,fff,13
|
10005,丸井悠,マルイハルカ,haru@hoge.jp,fff,13
|
||||||
10006,涼元香織,スズモトカオリ,suzumoto@hoge.jp,ggg,13
|
10006,涼元香織,スズモトカオリ,suzumoto@hoge.jp,ggg,13
|
||||||
10007,葉山稔,ハヤマミノル,mhayama@hoge.jp,hhh,14
|
10007,葉山稔,ハヤマミノル,mhayama@hoge.jp,hhh,14
|
||||||
10008,川上朱里,カワカミアカリ,kawakami@hoge.jp,iii,14
|
10008,川上朱里,カワカミアカリ,kawakami@hoge.jp,iii,14
|
||||||
10009,杉井肇,スギイハジメ,sugi@hoge.jp,jjj,15
|
10009,杉井肇,スギイハジメ,sugi@hoge.jp,jjj,15
|
||||||
|
2,2,2,2,2,2
|
||||||
|
|||||||
|
Reference in New Issue
Block a user