Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 127b824ceb | |||
| 3f20a2a872 | |||
| 19563fbbbb | |||
| 0ab032f2e3 | |||
| 91dac26b86 | |||
| 548e172d7d |
6
.classpath
Normal file
6
.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
</classpath>
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/bin/
|
||||
/build/
|
||||
23
.project
Normal file
23
.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>em-oop</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
9
.settings/org.eclipse.jdt.core.prefs
Normal file
9
.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||
org.eclipse.jdt.core.compiler.compliance=21
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
||||
4
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
4
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="21"/>
|
||||
</faceted-project>
|
||||
@@ -1,27 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class BasicCheck1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
//コンストラクタ
|
||||
Book book1 = new Book();
|
||||
|
||||
//book1
|
||||
System.out.println(book1.title);
|
||||
System.out.println(book1.author);
|
||||
System.out.println(book1.price);
|
||||
|
||||
//コンストラクタ
|
||||
Book book2 = new Book(
|
||||
"銀河鉄道の夜",
|
||||
"宮沢賢治",
|
||||
500);
|
||||
|
||||
//book2
|
||||
System.out.println(book2.title);
|
||||
System.out.println(book2.author);
|
||||
System.out.println(book2.price);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class BasicCheck2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
Student student1 = new Student(1, "鈴木一郎");
|
||||
Student student2 = new Student(2, "田中花子");
|
||||
Student student3 = new Student(3, "佐藤次郎");
|
||||
|
||||
// 学生情報表示
|
||||
student1.printProfile();
|
||||
student2.printProfile();
|
||||
student3.printProfile();
|
||||
|
||||
// 現在の学生数表示
|
||||
System.out.println(
|
||||
"現在の生徒数:"
|
||||
+ Student.getStudentCount()
|
||||
+ "人");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class BasicCheck3 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
// Item型の配列を作成
|
||||
Item[] items = new Item[3];
|
||||
|
||||
//インスタンス生成
|
||||
items[0] = new Item();
|
||||
items[1] = new Item();
|
||||
items[2] = new Item();
|
||||
|
||||
items[0].setName("ノート");
|
||||
items[0].setPrice(120);
|
||||
items[0].setStock(50);
|
||||
|
||||
items[1].setName("消しゴム");
|
||||
items[1].setPrice(80);
|
||||
items[1].setStock(30);
|
||||
|
||||
items[2].setName("鉛筆");
|
||||
items[2].setPrice(60);
|
||||
items[2].setStock(100);
|
||||
|
||||
//販売
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i].sell(5);
|
||||
}
|
||||
//商品情報表示
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
System.out.println(items[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
28
Book.java
28
Book.java
@@ -1,28 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class Book {
|
||||
// タイトル
|
||||
String title;
|
||||
// 著者
|
||||
String author;
|
||||
// 価格
|
||||
int price;
|
||||
|
||||
//コンストラクタ
|
||||
public Book() {
|
||||
|
||||
this.title = "タイトル未設定";
|
||||
this.author = "著者未設定";
|
||||
this.price = 0;
|
||||
}
|
||||
|
||||
//コンストラクタ
|
||||
public Book(String title, String author, int price) {
|
||||
|
||||
//フィールド代入
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.price = price;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class EmployeeData {
|
||||
//社員ID
|
||||
private String idEmployee;
|
||||
//社員名
|
||||
private String nmEmployee;
|
||||
//社員名カナ
|
||||
private String knEmployee;
|
||||
//メールアドレス
|
||||
private String mailAddress;
|
||||
//パスワード
|
||||
private String password;
|
||||
//部署ID
|
||||
private String idDepartment;
|
||||
//社員データ件数
|
||||
private static int empCount = 0;
|
||||
//コンストラクタ
|
||||
public EmployeeData() {
|
||||
empCount++;
|
||||
}
|
||||
//コンストラクタ
|
||||
public EmployeeData(
|
||||
String idEmployee,
|
||||
String nmEmployee,
|
||||
String knEmployee,
|
||||
String mailAddress,
|
||||
String password,
|
||||
String idDepartment) {
|
||||
|
||||
this.setIdEmployee(idEmployee);
|
||||
this.setNmEmployee(nmEmployee);
|
||||
this.setKnEmployee(knEmployee);
|
||||
this.setMailAddress(mailAddress);
|
||||
this.setPassword(password);
|
||||
this.setIdDepartment(idDepartment);
|
||||
empCount++;
|
||||
|
||||
}
|
||||
//ゲッター
|
||||
public String getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
public String getKnEmployee() {
|
||||
return knEmployee;
|
||||
}
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
//セッター
|
||||
public void setIdEmployee(String idEmployee) {
|
||||
//nullチェック
|
||||
if (idEmployee == null) {
|
||||
System.out.println("社員IDが空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
//空文字チェック
|
||||
if (idEmployee.trim().isEmpty()) {
|
||||
System.out.println( "社員IDが空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
this.idEmployee = idEmployee;
|
||||
}
|
||||
public void setNmEmployee(String nmEmployee) {
|
||||
//nullチェック
|
||||
if (nmEmployee == null) {
|
||||
System.out.println("社員名が空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
//空文字チェック
|
||||
if (nmEmployee.trim().isEmpty()) {
|
||||
System.out.println("社員名が空のため設定できませんでした");
|
||||
return;
|
||||
}
|
||||
this.nmEmployee = nmEmployee;
|
||||
}
|
||||
public void setKnEmployee(String knEmployee) {
|
||||
this.knEmployee = knEmployee;
|
||||
}
|
||||
public void setMailAddress(String mailAddress) {
|
||||
this.mailAddress = mailAddress;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public void setIdDepartment(String idDepartment) {
|
||||
this.idDepartment = idDepartment;
|
||||
}
|
||||
//toString
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return getIdEmployee() + "\t"
|
||||
+ getNmEmployee() + "\t"
|
||||
+ getKnEmployee() + "\t"
|
||||
+ getMailAddress() + "\t"
|
||||
+ getPassword() + "\t"
|
||||
+ getIdDepartment();
|
||||
}
|
||||
|
||||
//ID一致判定
|
||||
public boolean isMatchId(String id) {
|
||||
return getIdEmployee().equals(id);
|
||||
}
|
||||
//件数取得
|
||||
public static int getEmpCount() {
|
||||
return empCount;
|
||||
}
|
||||
}
|
||||
52
Item.java
52
Item.java
@@ -1,52 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class Item {
|
||||
private String name;
|
||||
private int price;
|
||||
private int stock;
|
||||
|
||||
//商品
|
||||
public void sell(int amount) {
|
||||
//在庫減らし
|
||||
this.setStock(this.getStock() - amount);
|
||||
}
|
||||
|
||||
//商品名ゲッター
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//商品名セッター
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//価格ゲッター
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
//価格セッター
|
||||
public void setPrice(int price) {
|
||||
this.price = price;
|
||||
}
|
||||
//在庫数ゲッター
|
||||
public int getStock() {
|
||||
return stock;
|
||||
}
|
||||
//在庫数セッター
|
||||
public void setStock(int stock) {
|
||||
this.stock = stock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return getName()
|
||||
+ " "
|
||||
+ getPrice()
|
||||
+ "円 (残り"
|
||||
+ getStock()
|
||||
+ "個)";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
80
Main.java
80
Main.java
@@ -1,80 +0,0 @@
|
||||
package misson1014;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
//配列を作成
|
||||
EmployeeData[] employees = new EmployeeData[5];
|
||||
|
||||
//インスタンス生成
|
||||
employees[0] = new EmployeeData();
|
||||
employees[1] = new EmployeeData();
|
||||
employees[2] = new EmployeeData();
|
||||
employees[3] = new EmployeeData();
|
||||
employees[4] = new EmployeeData();
|
||||
|
||||
employees[0].setIdEmployee("10000");
|
||||
employees[0].setNmEmployee("山田龍也");
|
||||
employees[0].setKnEmployee("ヤマダタツヤ");
|
||||
employees[0].setMailAddress("yamada@hoge.jp");
|
||||
employees[0].setPassword("aaa");
|
||||
employees[0].setIdDepartment("10");
|
||||
|
||||
employees[1].setIdEmployee("10001");
|
||||
employees[1].setNmEmployee("高橋準");
|
||||
employees[1].setKnEmployee("タカハシジュン");
|
||||
employees[1].setMailAddress("jtaka@hoge.jp");
|
||||
employees[1].setPassword("bbb");
|
||||
employees[1].setIdDepartment("10");
|
||||
|
||||
employees[2].setIdEmployee("10002");
|
||||
employees[2].setNmEmployee("麻枝史明");
|
||||
employees[2].setKnEmployee("マエダフミアキ");
|
||||
employees[2].setMailAddress("fmak@hoge.jp");
|
||||
employees[2].setPassword("ccc");
|
||||
employees[2].setIdDepartment("11");
|
||||
|
||||
employees[3].setIdEmployee("10003");
|
||||
employees[3].setNmEmployee("丸戸章介");
|
||||
employees[3].setKnEmployee("マルトショウスケ");
|
||||
employees[3].setMailAddress("marusyo@hoge.jp");
|
||||
employees[3].setPassword("ddd");
|
||||
employees[3].setIdDepartment("12");
|
||||
|
||||
employees[4].setIdEmployee("10004");
|
||||
employees[4].setNmEmployee("三宅武");
|
||||
employees[4].setKnEmployee("ミヤケタケシ");
|
||||
employees[4].setMailAddress("miya@hoge.jp");
|
||||
employees[4].setPassword("eee");
|
||||
employees[4].setIdDepartment("13");
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
//0が入力されるまでループ
|
||||
while (true) {
|
||||
//ID入力
|
||||
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||
String search = scanner.nextLine();
|
||||
if (search.equals("0")) { System.out.println("システムを終了します");
|
||||
break;
|
||||
}
|
||||
//見つかったかどうか
|
||||
boolean found = false;
|
||||
//検索処理
|
||||
for (int i = 0; i < employees.length; i++) {
|
||||
if (employees[i].isMatchId(search)) {
|
||||
System.out.println(employees[i]);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 見つからなかった場合
|
||||
if (!found) {System.out.println("該当する社員が見つかりませんでした");
|
||||
}
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
}
|
||||
91
Main1.java
91
Main1.java
@@ -1,91 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class Main1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
//8段階目まで
|
||||
|
||||
/*
|
||||
EmployeeData[] employees = new EmployeeData[5];
|
||||
|
||||
employees[0] = new EmployeeData();
|
||||
employees[1] = new EmployeeData();
|
||||
employees[2] = new EmployeeData();
|
||||
employees[3] = new EmployeeData();
|
||||
employees[4] = new EmployeeData();
|
||||
|
||||
employees[0].setIdEmployee("10000");
|
||||
|
||||
8段階用
|
||||
employees[0].setNmEmployee("");
|
||||
|
||||
employees[0].setKnEmployee("ヤマダタツヤ");
|
||||
employees[0].setMailAddress("yamada@hoge.jp");
|
||||
employees[0].setPassword("aaa");
|
||||
employees[0].setIdDepartment("10");
|
||||
|
||||
employees[1].setIdEmployee("10001");
|
||||
employees[1].setNmEmployee("高橋準");
|
||||
employees[1].setKnEmployee("タカハシジュン");
|
||||
employees[1].setMailAddress("jtaka@hoge.jp");
|
||||
employees[1].setPassword("bbb");
|
||||
employees[1].setIdDepartment("10");
|
||||
|
||||
employees[2].setIdEmployee("10002");
|
||||
employees[2].setNmEmployee("麻枝史明");
|
||||
employees[2].setKnEmployee("マエダフミアキ");
|
||||
employees[2].setMailAddress("fmak@hoge.jp");
|
||||
employees[2].setPassword("ccc");
|
||||
employees[2].setIdDepartment("11");
|
||||
|
||||
employees[3].setIdEmployee("10003");
|
||||
employees[3].setNmEmployee("丸戸章介");
|
||||
employees[3].setKnEmployee("マルトショウスケ");
|
||||
employees[3].setMailAddress("marusyo@hoge.jp");
|
||||
employees[3].setPassword("ddd");
|
||||
employees[3].setIdDepartment("12");
|
||||
|
||||
employees[4].setIdEmployee("10004");
|
||||
employees[4].setNmEmployee("三宅武");
|
||||
employees[4].setKnEmployee("ミヤケタケシ");
|
||||
employees[4].setMailAddress("miya@hoge.jp");
|
||||
employees[4].setPassword("eee");
|
||||
employees[4].setIdDepartment("13");
|
||||
|
||||
for (int i = 0; i < employees.length; i++) {
|
||||
|
||||
System.out.println(employees[i]);
|
||||
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"現在の社員データ件数:"
|
||||
+ EmployeeData.getEmpCount()
|
||||
+ "件");
|
||||
*/
|
||||
|
||||
//ここから9段階↓
|
||||
EmployeeData employee1 =
|
||||
new EmployeeData(
|
||||
"10000",
|
||||
"",
|
||||
"ヤマダタツヤ",
|
||||
"yamada@hoge.jp",
|
||||
"aaa",
|
||||
"10"
|
||||
);
|
||||
|
||||
EmployeeData employee2 =
|
||||
new EmployeeData(
|
||||
"",
|
||||
"山田龍也",
|
||||
"ヤマダタツヤ",
|
||||
"yamada@hoge.jp",
|
||||
"aaa",
|
||||
"10"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
31
Student.java
31
Student.java
@@ -1,31 +0,0 @@
|
||||
package misson1014;
|
||||
|
||||
public class Student {
|
||||
int studentId;
|
||||
String name;
|
||||
//staticフィールド
|
||||
static int studentCount = 0;
|
||||
|
||||
//コンストラクタ
|
||||
public Student(int studentId, String name) {
|
||||
//フィールド代入
|
||||
this.studentId = studentId;
|
||||
this.name = name;
|
||||
studentCount++;
|
||||
}
|
||||
|
||||
//学生情報
|
||||
void printProfile() {
|
||||
|
||||
System.out.println(
|
||||
"学籍番号:" + this.studentId
|
||||
+ " 名前:" + this.name);
|
||||
}
|
||||
|
||||
//現在の学生数用staticメソッド
|
||||
public static int getStudentCount() {
|
||||
return studentCount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
110
src/main/java/EmployeeData.java
Normal file
110
src/main/java/EmployeeData.java
Normal file
@@ -0,0 +1,110 @@
|
||||
|
||||
public class EmployeeData {
|
||||
|
||||
static final String COMPANY_NAME = "Rhizome";
|
||||
private static int empCount = 0;
|
||||
private String idEmployee;
|
||||
private String nmEmployee;
|
||||
private String knEmployee;
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
private String idDepartment;
|
||||
|
||||
public EmployeeData() {
|
||||
empCount++;
|
||||
}
|
||||
|
||||
public EmployeeData(String idEmployee,
|
||||
String nmEmployee,
|
||||
String knEmployee,
|
||||
String mailAddress,
|
||||
String password,
|
||||
String idDepartment) {
|
||||
this.setIdEmployee(idEmployee);
|
||||
this.setNmEmployee(nmEmployee);
|
||||
this.setKnEmployee(knEmployee);
|
||||
this.setMailAddress(mailAddress);
|
||||
this.setPassword(password);
|
||||
this.setIdDepartment(idDepartment);
|
||||
empCount++;
|
||||
}
|
||||
|
||||
public String getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
public void setIdEmployee(String idEmployee) {
|
||||
if (idEmployee.strip().length()==0) {
|
||||
System.out.println("社員IDが空のため設定できませんでした");
|
||||
System.exit(0);
|
||||
} else {
|
||||
this.idEmployee = idEmployee;
|
||||
}
|
||||
}
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
public void setNmEmployee(String nmEmployee) {
|
||||
if (nmEmployee.strip().length()==0) {
|
||||
System.out.println("社員名が空のため設定できませんでした");
|
||||
System.exit(0);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
public String getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public void setIdDepartment(String idDepartment) {
|
||||
this.idDepartment = idDepartment;
|
||||
}
|
||||
|
||||
public static int getEmpCount() {
|
||||
return empCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return this.getIdEmployee()+"\t"
|
||||
+this.getNmEmployee()+"\t"
|
||||
+this.getKnEmployee()+"\t"
|
||||
+this.getMailAddress()+"\t"
|
||||
+this.getPassword()+"\t"
|
||||
+this.getIdDepartment();
|
||||
|
||||
}
|
||||
|
||||
public boolean isMatchId(String id) {
|
||||
return id.equals(this.getIdEmployee()) ;
|
||||
}
|
||||
|
||||
}
|
||||
98
src/main/java/Main.java
Normal file
98
src/main/java/Main.java
Normal file
@@ -0,0 +1,98 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
|
||||
|
||||
//====================設定====================
|
||||
EmployeeData[] employees = new EmployeeData[5];
|
||||
|
||||
// EmployeeData employee0 = new EmployeeData();
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
//====================表示====================
|
||||
System.out.println(EmployeeData.COMPANY_NAME);
|
||||
for ( EmployeeData employee : employees ) {
|
||||
System.out.println(employee);
|
||||
}
|
||||
System.out.println("現在の社員データ件数:"+EmployeeData.getEmpCount()+"件");
|
||||
|
||||
|
||||
//====================検索====================
|
||||
while (true) {
|
||||
|
||||
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String id = sc.nextLine();
|
||||
|
||||
if ( id.equals("0") ) {
|
||||
System.out.println("システムを終了します");
|
||||
break;
|
||||
}
|
||||
|
||||
boolean matchId = false;
|
||||
for ( EmployeeData employee : employees ) {
|
||||
if ( employee.isMatchId(id) ) {
|
||||
matchId = true;
|
||||
System.out.println(employee);;
|
||||
}
|
||||
}
|
||||
if ( matchId==false ) {
|
||||
System.out.println("該当する社員が見つかりませんでした");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user