Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94dfb97b76 | |||
| 77d3cbfcc6 |
@@ -1,6 +0,0 @@
|
||||
<?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
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/bin/
|
||||
/build/
|
||||
23
.project
23
.project
@@ -1,23 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,9 +0,0 @@
|
||||
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
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="21"/>
|
||||
</faceted-project>
|
||||
17
EmployeeData_20261014_hirayama.java
Normal file
17
EmployeeData_20261014_hirayama.java
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
public class EmployeeData {
|
||||
//フィールド
|
||||
String idEmployee;
|
||||
String nmEmployee;
|
||||
String knEmployee;
|
||||
String mailAddress;
|
||||
String password;
|
||||
String idDepartment;
|
||||
|
||||
//メソッド
|
||||
public void showInfo(String employee[]) {
|
||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee + "\t" + this.knEmployee + "\t" + this.mailAddress + "\t" + this.password + "\t" + this.idDepartment);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
61
Main_20261014_hirayama.java
Normal file
61
Main_20261014_hirayama.java
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
|
||||
EmployeeData[] employee = new EmployeeData[5];
|
||||
|
||||
//インスタンス生成
|
||||
/*EmployeeData em1 = new EmployeeData();
|
||||
EmployeeData em2 = new EmployeeData();
|
||||
EmployeeData em3 = new EmployeeData();
|
||||
EmployeeData em4 = new EmployeeData();
|
||||
EmployeeData em5 = new EmployeeData();*/
|
||||
|
||||
|
||||
//代入
|
||||
employee[0].idEmployee = "10000";
|
||||
employee[0].nmEmployee = "山田龍也";
|
||||
employee[0].knEmployee = "ヤマダタツヤ";
|
||||
employee[0].mailAddress = "yamada@hoge.jp";
|
||||
employee[0].password = "aaa";
|
||||
employee[0].idDepartment = "10";
|
||||
|
||||
employee[1].idEmployee = "10001";
|
||||
employee[1].nmEmployee = "高橋準";
|
||||
employee[1].knEmployee = "タカハシジュン";
|
||||
employee[1].mailAddress = "jtaka@hoge.jp";
|
||||
employee[1].password = "bbb";
|
||||
employee[1].idDepartment = "10";
|
||||
|
||||
employee[2].idEmployee = "10002";
|
||||
employee[2].nmEmployee = "麻枝史明";
|
||||
employee[2].knEmployee = "マエダフミアキ";
|
||||
employee[2].mailAddress = "fmak@hoge.jp";
|
||||
employee[2].password = "ccc";
|
||||
employee[2].idDepartment = "11";
|
||||
|
||||
employee[3].idEmployee = "10003";
|
||||
employee[3].nmEmployee = "丸戸章介";
|
||||
employee[3].knEmployee = "マルトショウスケ";
|
||||
employee[3].mailAddress = "marusyo@hoge.jp";
|
||||
employee[3].password = "ddd";
|
||||
employee[3].idDepartment = "12";
|
||||
|
||||
employee[4].idEmployee = "10004";
|
||||
employee[4].nmEmployee = "三宅武";
|
||||
employee[4].knEmployee = "ミヤケタケシ";
|
||||
employee[4].mailAddress = "miya@hoge.jp";
|
||||
employee[4].password = "eee";
|
||||
employee[4].idDepartment = "13";
|
||||
|
||||
/*メソッド呼び出し
|
||||
for(int i = 0; i < 5; i++) {
|
||||
employee[].showInfo();
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
24
ObjectSample_20261014_hirayama.java
Normal file
24
ObjectSample_20261014_hirayama.java
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
public class ObjectSample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
//原本のコピー(インスタンス生成)
|
||||
Student student1 = new Student();
|
||||
Student student2 = new Student();
|
||||
|
||||
//name、ageへの代入
|
||||
student1.name = "田中";
|
||||
student1.age = 30;
|
||||
|
||||
student2.name = "山本";
|
||||
student2.age = 25;
|
||||
|
||||
//introduceメソッドの呼び出し
|
||||
student1.intoroduce();
|
||||
|
||||
student2.intoroduce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
Student_20261014_hirayama.java
Normal file
13
Student_20261014_hirayama.java
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
public class Student {
|
||||
//フィールドの宣言
|
||||
String name;
|
||||
int age;
|
||||
|
||||
//メソッドの定義
|
||||
public void intoroduce() {
|
||||
System.out.println("私の名前は" + this.name);
|
||||
System.out.println("年齢は" + this.age);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
|
||||
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()) ;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
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