Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 127b824ceb | |||
| 3f20a2a872 | |||
| 19563fbbbb | |||
| 0ab032f2e3 | |||
| 91dac26b86 | |||
| 548e172d7d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
|
/bin/
|
||||||
/build/
|
/build/
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck1 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// 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,13 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck2 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Student student = new Student();
|
|
||||||
student.studentId = 1;
|
|
||||||
student.name = "鈴木一郎";
|
|
||||||
|
|
||||||
student.printProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck3 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Item[] items = new Item[3];
|
|
||||||
|
|
||||||
items[0] = new Item();
|
|
||||||
items[0].name = "ノート";
|
|
||||||
items[0].price = 120;
|
|
||||||
items[0].stock = 50;
|
|
||||||
|
|
||||||
|
|
||||||
items[1] = new Item();
|
|
||||||
items[1].name = "消しゴム";
|
|
||||||
items[1] .price = 80;
|
|
||||||
items[1].stock = 30;
|
|
||||||
|
|
||||||
|
|
||||||
items[2] = new Item();
|
|
||||||
items[2].name = "鉛筆";
|
|
||||||
items[2].price = 60;
|
|
||||||
items[2].stock = 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].name + " 価格:" + items[i].price + "円 在庫:" + items[i].stock );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
public class Book {
|
|
||||||
String title;
|
|
||||||
String author;
|
|
||||||
int price;
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,110 @@
|
|||||||
|
|
||||||
public class EmployeeData {
|
public class EmployeeData {
|
||||||
String idEmployee;
|
|
||||||
String nmEmployee;
|
|
||||||
String knEmployee;
|
|
||||||
String mailAddress;
|
|
||||||
String password;
|
|
||||||
String idDepartment;
|
|
||||||
|
|
||||||
|
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 void showInfo(){
|
public EmployeeData(String idEmployee,
|
||||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + "\t" + this.mailAddress + "\t" + this.password + "\t" + this.idDepartment);
|
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()) ;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
public class Item {
|
|
||||||
String name;
|
|
||||||
int price;
|
|
||||||
int stock;
|
|
||||||
|
|
||||||
public void sell(int amount) {
|
|
||||||
this.stock = this.stock - amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +1,98 @@
|
|||||||
|
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[] employees = new EmployeeData[5];
|
EmployeeData[] employees = new EmployeeData[5];
|
||||||
|
|
||||||
employees[0] = new EmployeeData();
|
// EmployeeData employee0 = new EmployeeData();
|
||||||
employees[0].idEmployee = "10000";
|
// employee0.setIdEmployee(""); // 社員IDが空文字のとき
|
||||||
employees[0].nmEmployee = "山田龍也";
|
// employee0.setNmEmployee(""); // 社員名が空文字のとき
|
||||||
employees[0].knEmployee = "ヤマダタツヤ";
|
|
||||||
employees[0].mailAddress = "yamada@hoge.jp";
|
|
||||||
employees[0].password = "aaa";
|
|
||||||
employees[0].idDepartment = "10";
|
|
||||||
|
|
||||||
employees[1] = new EmployeeData();
|
EmployeeData employee1 = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
||||||
employees[1].idEmployee = "10001";
|
// EmployeeData employee1 = new EmployeeData();
|
||||||
employees[1].nmEmployee = "高橋準";
|
// employee1.setIdEmployee("10000");
|
||||||
employees[1].knEmployee = "タカハシジュン";
|
// employee1.setNmEmployee("山田龍也");
|
||||||
employees[1].mailAddress = "jtaka@hoge.jp";
|
// employee1.setKnEmployee("ヤマダタツヤ");
|
||||||
employees[1].password = "bbb";
|
// employee1.setMailAddress("yamada@hoge.jp");
|
||||||
employees[1].idDepartment = "10";
|
// employee1.setPassword("aaa");
|
||||||
|
// employee1.setIdDepartment("10");
|
||||||
|
employees[1-1] = employee1;
|
||||||
|
|
||||||
employees[2] = new EmployeeData();
|
EmployeeData employee2 = new EmployeeData();
|
||||||
employees[2].idEmployee = "10002";
|
employee2.setIdEmployee("10001");
|
||||||
employees[2].nmEmployee = "麻枝史明";
|
employee2.setNmEmployee("高橋準");
|
||||||
employees[2].knEmployee = "マエダフミアキ";
|
employee2.setKnEmployee("タカハシジュン");
|
||||||
employees[2].mailAddress = "fmak@hoge.jp";
|
employee2.setMailAddress("jtaka@hoge.jp");
|
||||||
employees[2].password = "ccc";
|
employee2.setPassword("bbb");
|
||||||
employees[2].idDepartment = "11";
|
employee2.setIdDepartment("10");
|
||||||
|
employees[2-1] = employee2;
|
||||||
|
|
||||||
employees[3] = new EmployeeData();
|
EmployeeData employee3 = new EmployeeData();
|
||||||
employees[3].idEmployee = "10003";
|
employee3.setIdEmployee("10002");
|
||||||
employees[3].nmEmployee = "丸戸章介";
|
employee3.setNmEmployee("麻枝史明");
|
||||||
employees[3].knEmployee = "マルトショウスケ";
|
employee3.setKnEmployee("マエダフミアキ");
|
||||||
employees[3].mailAddress = "marusyo@hoge.jp";
|
employee3.setMailAddress("fmak@hoge.jp");
|
||||||
employees[3].password = "ddd";
|
employee3.setPassword("ccc");
|
||||||
employees[3].idDepartment = "12";
|
employee3.setIdDepartment("11");
|
||||||
|
employees[3-1] = employee3;
|
||||||
|
|
||||||
employees[4] = new EmployeeData();
|
EmployeeData employee4 = new EmployeeData();
|
||||||
employees[4].idEmployee = "10004";
|
employee4.setIdEmployee("10003");
|
||||||
employees[4].nmEmployee = "三宅武";
|
employee4.setNmEmployee("丸戸章介");
|
||||||
employees[4].knEmployee = "ミヤケタケシ";
|
employee4.setKnEmployee("マルトショウスケ");
|
||||||
employees[4].mailAddress = "miya@hoge.jp";
|
employee4.setMailAddress("marusyo@hoge.jp");
|
||||||
employees[4].password = "eee";
|
employee4.setPassword("ddd");
|
||||||
employees[4].idDepartment = "13";
|
employee4.setIdDepartment("12");
|
||||||
|
employees[4-1] = employee4;
|
||||||
|
|
||||||
for (int i = 0; i < employees.length; i++) {
|
EmployeeData employee5 = new EmployeeData();
|
||||||
employees[i].showInfo();
|
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("該当する社員が見つかりませんでした");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
public class Student {
|
|
||||||
|
|
||||||
int studentId;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
|
|
||||||
public void printProfile() {
|
|
||||||
System.out.println("学籍番号:"+this.studentId+" 名前:"+this.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user