最終日
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
public class EmployeeData extends BaseData {
|
||||
|
||||
public class EmployeeData {
|
||||
private String idEmployee;
|
||||
private String nmEmployee;
|
||||
private String knEmployee;
|
||||
@@ -9,80 +9,60 @@
|
||||
|
||||
|
||||
|
||||
private static int empCount = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setIdEmployee(String idEmployee) {
|
||||
if (idEmployee == null || idEmployee == " " ||idEmployee == " " || idEmployee.isEmpty()) {
|
||||
System.out.println("社員IDが空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
this.idEmployee = idEmployee;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setNmEmployee(String nmEmployee) {
|
||||
if (nmEmployee == null || nmEmployee == " " || nmEmployee == " " || nmEmployee.isEmpty()){
|
||||
System.out.println("社員名が空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -92,6 +72,7 @@
|
||||
|
||||
|
||||
public String getIdDepartment() {
|
||||
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
@@ -104,6 +85,20 @@
|
||||
}
|
||||
|
||||
|
||||
public boolean isMatchId(String id) {
|
||||
|
||||
|
||||
|
||||
if (this.idEmployee != null && this.idEmployee.equals(id)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void showInfo() {
|
||||
System.out.println(this.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -113,14 +108,35 @@
|
||||
}
|
||||
|
||||
public EmployeeData() {
|
||||
empCount++;
|
||||
}
|
||||
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee,String mailAddress, String password, String idDepartment) {
|
||||
setIdEmployee(idEmployee);
|
||||
setNmEmployee(nmEmployee);
|
||||
setKnEmployee(knEmployee);
|
||||
setMailAddress(mailAddress);
|
||||
setPassword(password);
|
||||
setIdDepartment(idDepartment);
|
||||
this.setIdEmployee(idEmployee);
|
||||
this.setNmEmployee(nmEmployee);
|
||||
this.setKnEmployee(knEmployee);
|
||||
this.setMailAddress(mailAddress);
|
||||
this.setPassword(password);
|
||||
this.setIdDepartment(idDepartment);
|
||||
empCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int getEmpCount() {
|
||||
return empCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCSV() {
|
||||
return getIdEmployee() + "," + getNmEmployee() + "," + getKnEmployee() + "," + getMailAddress() + "," + getPassword() + "," + getIdDepartment();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryKeyValue(){
|
||||
return this.idEmployee;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
EmployeeData[] employees = new EmployeeData[5];
|
||||
BaseData[] employees = new BaseData[5];
|
||||
|
||||
|
||||
employees[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
||||
employees[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
|
||||
@@ -12,10 +14,60 @@ public class Main {
|
||||
employees[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "13");
|
||||
|
||||
for (int i = 0; i < employees.length; i++) {
|
||||
System.out.println(employees[i]);
|
||||
|
||||
//System.out.println(employees[i]);
|
||||
|
||||
}
|
||||
|
||||
System.out.println("現在のデータ件数:"+EmployeeData.getEmpCount()+"件");
|
||||
|
||||
|
||||
while (true) {
|
||||
|
||||
|
||||
|
||||
|
||||
//Scannerを使って、
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
//「検索したい社員IDを入力してください」と表示し
|
||||
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||
//キーボード入力を受け取る
|
||||
String idEmployee = scanner.next();
|
||||
|
||||
|
||||
|
||||
if ("0".equals(idEmployee)) {
|
||||
System.out.println("システムを終了します");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//employees配列をfor文で1件ずつ確認し
|
||||
for(int i = 0; i < employees.length; i++) {
|
||||
|
||||
|
||||
|
||||
if (((EmployeeData) employees[i]).isMatchId(idEmployee)) {
|
||||
//一致する社員が見つかったら、その社員のshowInfoメソッドを呼び出す
|
||||
((EmployeeData) employees[i]).showInfo();
|
||||
}
|
||||
else {
|
||||
//
|
||||
System.out.println("検索したいIDが見つかりませんでした");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//System.out.println(employees[0].toCSV());
|
||||
//System.out.println(employees[0].getPrimaryKeyValue());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user