Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 493c8ea3f5 | |||
| 030642e41c | |||
| b688f210f1 | |||
| 70ceeecf70 |
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>
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/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>
|
||||||
7
src/main/java/BaseDate.java
Normal file
7
src/main/java/BaseDate.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
public abstract class BaseDate {
|
||||||
|
|
||||||
|
public abstract String toString();
|
||||||
|
public abstract String toCSV();
|
||||||
|
public abstract String getPrimaryKeyValue();
|
||||||
|
}
|
||||||
165
src/main/java/EmployeeData.java
Normal file
165
src/main/java/EmployeeData.java
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
public class EmployeeData extends BaseDate {
|
||||||
|
|
||||||
|
//フィールドの宣言
|
||||||
|
//社員ID
|
||||||
|
private String idEmployee;
|
||||||
|
//社員名
|
||||||
|
private String nmEmployee;
|
||||||
|
//社員名カナ
|
||||||
|
private String knEmployee;
|
||||||
|
//メールアドレス
|
||||||
|
private String mailAddress;
|
||||||
|
//パスワード
|
||||||
|
private String password;
|
||||||
|
//部署ID
|
||||||
|
private String idDepartment;
|
||||||
|
|
||||||
|
public static int empCount;
|
||||||
|
|
||||||
|
|
||||||
|
//ゲッターとセッター
|
||||||
|
public String getIdEmployee() {
|
||||||
|
return idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdEmployee(String idEmployee) {
|
||||||
|
this.idEmployee = idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getNmEmployee() {
|
||||||
|
return nmEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setNmEmployee(String nmEmployee) {
|
||||||
|
|
||||||
|
if(nmEmployee == null) {
|
||||||
|
System.out.println("社員名が空のため設定できませんでした");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.nmEmployee = nmEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
//文字列前後の空白を取り除く
|
||||||
|
String trimmednmEmployee = nmEmployee.trim();
|
||||||
|
//文字列の長さを調べる
|
||||||
|
int count = trimmednmEmployee.length();
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
System.out.println("社員名が空のため設定できませんでした");
|
||||||
|
}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) {
|
||||||
|
if(idDepartment == null) {
|
||||||
|
System.out.println("社員IDが空のため設定できませんでした");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.idDepartment = idDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
|
//文字列前後の空白を取り除く
|
||||||
|
String trimmednmEmployee = nmEmployee.trim();
|
||||||
|
//文字列の長さを調べる
|
||||||
|
int count = trimmednmEmployee.length();
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
System.out.println("社員IDがのため設定できませんでした");
|
||||||
|
}else {
|
||||||
|
this.idDepartment = idDepartment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static int getEmpCount() {
|
||||||
|
return empCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEmpCount(int empCount) {
|
||||||
|
EmployeeData.empCount = empCount ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//コンストラクタの作成
|
||||||
|
public EmployeeData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, String idDepartment, int empCount) {
|
||||||
|
this.setIdEmployee(idEmployee);
|
||||||
|
this.setNmEmployee(nmEmployee);
|
||||||
|
this.setKnEmployee(knEmployee);
|
||||||
|
this.setMailAddress(mailAddress);
|
||||||
|
this.setPassword(password);
|
||||||
|
this.setIdDepartment(idDepartment);
|
||||||
|
this.setEmpCount(empCount);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//メソッドの作成
|
||||||
|
|
||||||
|
@Override public String toString() {
|
||||||
|
|
||||||
|
return (getIdEmployee() +"\t"+ getNmEmployee() +"\t"+ getKnEmployee() +"\t"+ getMailAddress() +"\t"+ getPassword() +"\t"+ getIdDepartment());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int EmpCount() {
|
||||||
|
return getEmpCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String toCSV(){
|
||||||
|
return (getIdEmployee() +","+ getNmEmployee() +","+ getKnEmployee() +","+ getMailAddress() +","+ getPassword() +","+ getIdDepartment());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getPrimaryKeyValue() {
|
||||||
|
return idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
32
src/main/java/em_oop_20261014.java
Normal file
32
src/main/java/em_oop_20261014.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
public class em_oop_20261014 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
|
||||||
|
//インスタンスの生成
|
||||||
|
EmployeeData[] employees = new EmployeeData[5];
|
||||||
|
|
||||||
|
employees[0] = new EmployeeData("10000", "山田達也", "ヤマダタツヤ","yamada@hoge.jp" ,"aaa", "10",0);
|
||||||
|
employees[1] = new EmployeeData("10001","高橋準","タカハシジュン","jtaka@hoge.jp","bbb","10",1);
|
||||||
|
employees[2] = new EmployeeData("10002","麻枝史明","マエダフミアキ","fmak@hoge.jp","ccc","11",2);
|
||||||
|
employees[3] = new EmployeeData("10003","丸戸章介","マルトショウスケ","marusyo@hoge.jp","ddd","12",3);
|
||||||
|
employees[4] = new EmployeeData("10004","三宅武","ミヤケタケシ","miya@hoge.jp","eee","13",4);
|
||||||
|
|
||||||
|
|
||||||
|
//呼び出し
|
||||||
|
System.out.println(employees[0]);
|
||||||
|
System.out.println(employees[1]);
|
||||||
|
System.out.println(employees[2]);
|
||||||
|
System.out.println(employees[3]);
|
||||||
|
System.out.println(employees[4]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("現在の社員データ件数:" + employees.length);
|
||||||
|
|
||||||
|
//employees.toCSV();
|
||||||
|
//employees.getPrimaryKeyValue();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user