Stept 8 done
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,3 +25,4 @@ hs_err_pid*
|
|||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
/.metadata/
|
/.metadata/
|
||||||
|
/bin/
|
||||||
|
|||||||
@@ -3,6 +3,19 @@ public class BasicCheck1 {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
Book book = new Book();
|
||||||
|
book.title = "吾輩は猫である";
|
||||||
|
book.author ="夏目漱石";
|
||||||
|
book.price = 800;
|
||||||
|
|
||||||
|
System.out.println(book.title);
|
||||||
|
System.out.println(book.author);
|
||||||
|
System.out.println(book.price);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
|
||||||
public class Book {
|
public class Book {
|
||||||
|
String title;
|
||||||
|
String author;
|
||||||
|
int price;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
|
|
||||||
public class EmployeeData {
|
public class EmployeeData {
|
||||||
String idEmployee;
|
String idEmployee;
|
||||||
String nmEmployee;
|
String nmEmployee;
|
||||||
String knEmployee;
|
String knEmployee;
|
||||||
String mailAddress;
|
String mailAddress;
|
||||||
String password;
|
String password;
|
||||||
String idDepartment;
|
String idDepartment;
|
||||||
|
|
||||||
void showInfo() {
|
|
||||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee + this.knEmployee+this.mailAddress+this.password+this.idDepartment);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void showInfo() {
|
||||||
|
System.out.println(this.idEmployee + "\t" + this.nmEmployee + this.knEmployee + this.mailAddress + this.password
|
||||||
|
+ this.idDepartment);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isMatchId(String id) { //stept 7
|
||||||
|
return this.idEmployee.equals(id);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,92 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
EmployeeData employee = new EmployeeData();
|
EmployeeData[] employees = new EmployeeData[5];
|
||||||
|
//1st person
|
||||||
employee.idEmployee = "10000";
|
employees[0] = new EmployeeData();
|
||||||
employee.nmEmployee = "山田龍也";
|
employees[0].idEmployee = "10000";
|
||||||
employee.knEmployee = "ヤマダタツヤ";
|
employees[0].nmEmployee = "山田龍也";
|
||||||
employee.mailAddress = "yamada@hoge.jp";
|
employees[0].knEmployee = "ヤマダタツヤ";
|
||||||
employee.password = "aaa";
|
employees[0].mailAddress = "yamada@hoge.jp";
|
||||||
employee.idDepartment = "10";
|
employees[0].password = "aaa";
|
||||||
|
employees[0].idDepartment = "10";
|
||||||
employee.showInfo();
|
//2nd person
|
||||||
|
employees[1] = new EmployeeData();
|
||||||
|
employees[1].idEmployee = "10001";
|
||||||
|
employees[1].nmEmployee = "高橋準";
|
||||||
|
employees[1].knEmployee = "タカハシジュン";
|
||||||
|
employees[1].mailAddress = "jtaka@hoge.jp";
|
||||||
|
employees[1].password = "bbb";
|
||||||
|
employees[1].idDepartment = "10";
|
||||||
|
//3rd person
|
||||||
|
employees[2] = new EmployeeData();
|
||||||
|
employees[2].idEmployee = "10002";
|
||||||
|
employees[2].nmEmployee = "麻枝史明";
|
||||||
|
employees[2].knEmployee = "マエダフミアキ";
|
||||||
|
employees[2].mailAddress = "fmak@hoge.jp";
|
||||||
|
employees[2].password = "ccc";
|
||||||
|
employees[2].idDepartment = "11";
|
||||||
|
//4th person
|
||||||
|
employees[3] = new EmployeeData();
|
||||||
|
employees[3].idEmployee = "10003";
|
||||||
|
employees[3].nmEmployee = "丸戸章介";
|
||||||
|
employees[3].knEmployee = "マルトショウスケ";
|
||||||
|
employees[3].mailAddress = "marusyo@hoge.jp";
|
||||||
|
employees[3].password = "ddd";
|
||||||
|
employees[3].idDepartment = "12";
|
||||||
|
//5th person
|
||||||
|
employees[4] = new EmployeeData();
|
||||||
|
employees[4].idEmployee = "10004";
|
||||||
|
employees[4].nmEmployee = "三宅武";
|
||||||
|
employees[4].knEmployee = "ミヤケタケシ";
|
||||||
|
employees[4].mailAddress = "miya@hoge.jp";
|
||||||
|
employees[4].password = "eee";
|
||||||
|
employees[4].idDepartment = "13";
|
||||||
|
// stept6
|
||||||
|
// for (int i = 0; i < employees.length; i++) {
|
||||||
|
// employees[i].showInfo();
|
||||||
|
// }
|
||||||
|
//stept 7
|
||||||
|
System.out.println("10002 を検索します");
|
||||||
|
System.out.println(employees[2].isMatchId("10002"));
|
||||||
|
|
||||||
// System.out.println(employee.idEmployee);
|
System.out.println("99999 を検索します");
|
||||||
// System.out.println(employee.nmEmployee);
|
System.out.println(employees[2].isMatchId("99999"));
|
||||||
// System.out.println(employee.knEmployee);
|
|
||||||
// System.out.println(employee.mailAddress);
|
//stept 5
|
||||||
// System.out.println(employee.password);
|
// employee.showInfo();
|
||||||
// System.out.println(employee.idDepartment);
|
// stept6
|
||||||
|
|
||||||
|
// System.out.println(employee.idEmployee);
|
||||||
|
// System.out.println(employee.nmEmployee);
|
||||||
|
// System.out.println(employee.knEmployee);
|
||||||
|
// System.out.println(employee.mailAddress);
|
||||||
|
// System.out.println(employee.password);
|
||||||
|
// System.out.println(employee.idDepartment);
|
||||||
|
|
||||||
|
//stept 8
|
||||||
|
Scanner scan = new Scanner(System.in);
|
||||||
|
System.out.println("検索したい社員IDを入力してください");
|
||||||
|
String serchId = scan.nextLine();
|
||||||
|
|
||||||
|
boolean found = false; //←if it haven't this boolean , they can't be decided true or false, so we should be make boolan name (found)
|
||||||
|
for (int i =0; i< employees.length; i++) {
|
||||||
|
if (employees[i].isMatchId(serchId)){
|
||||||
|
employees[i].showInfo();
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!found) {
|
||||||
|
System.out.println("該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
scan.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user