Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04ef2b8b1f | |||
| b17babd071 | |||
| 24aa555e45 | |||
| d656d3c5a8 | |||
| 7e61a24d20 | |||
| 9223c5810c |
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/
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>CUI_EM_OOP</name>
|
<name>em-oop</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
@@ -10,8 +10,14 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=21
|
org.eclipse.jdt.core.compiler.compliance=21
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
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.problem.reportPreviewFeatures=warning
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
org.eclipse.jdt.core.compiler.source=21
|
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,10 +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">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="module" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
encoding/<project>=UTF-8
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck1 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Book book = new Book();
|
|
||||||
// book.title = "吾輩は猫である";
|
|
||||||
// book.author = "夏目漱石";
|
|
||||||
// book.price = 800;
|
|
||||||
|
|
||||||
// book.output();
|
|
||||||
|
|
||||||
Book book1 = new Book();
|
|
||||||
|
|
||||||
|
|
||||||
book1.output();
|
|
||||||
|
|
||||||
Book book2 = new Book();
|
|
||||||
book2.title = "銀河鉄道の夜";
|
|
||||||
book2.author = "宮沢賢治";
|
|
||||||
book2.price = 500;
|
|
||||||
|
|
||||||
book2.output();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
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,27 +0,0 @@
|
|||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void output() {
|
|
||||||
System.out.println(this.title);
|
|
||||||
System.out.println(this.author);
|
|
||||||
System.out.println(this.price);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
public class Circle extends Shape{
|
|
||||||
|
|
||||||
private double radius;
|
|
||||||
|
|
||||||
public Circle(double radius) {
|
|
||||||
|
|
||||||
super("円");
|
|
||||||
this.radius = radius;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double area() {
|
|
||||||
return Math.PI * radius * radius;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void showInfo() {
|
|
||||||
super.showInfo();
|
|
||||||
System.out.println("(半径:" + this.radius + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
public class Day3Check1 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Circle circle= new Circle(2);
|
|
||||||
circle.showInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
public class DepartmentData extends BaseData{
|
|
||||||
private String idDepartment;
|
|
||||||
private String nmDepartment;
|
|
||||||
|
|
||||||
|
|
||||||
public String getIdDepartment() {
|
|
||||||
return idDepartment;
|
|
||||||
}
|
|
||||||
public void setIdDepartment(String idDepartment) {
|
|
||||||
this.idDepartment = idDepartment;
|
|
||||||
}
|
|
||||||
public String getNmDepartment() {
|
|
||||||
return nmDepartment;
|
|
||||||
}
|
|
||||||
public void setNmDepartment(String nmDepartment) {
|
|
||||||
this.nmDepartment = nmDepartment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getIdDepartment() + "\t" + getNmDepartment();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toCSV() {
|
|
||||||
return getIdDepartment() + "," + getNmDepartment();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrimaryKeyValue() {
|
|
||||||
return getIdDepartment();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
public class EmployeeData extends BaseData {
|
|
||||||
private String idEmployee;
|
|
||||||
private String nmEmployee;
|
|
||||||
private String knEmployee;
|
|
||||||
private String mailAddress;
|
|
||||||
private String password;
|
|
||||||
private String idDepartment;
|
|
||||||
|
|
||||||
private static int empCount = 0;
|
|
||||||
// 引数なしコンストラクタ
|
|
||||||
public EmployeeData() {
|
|
||||||
|
|
||||||
}
|
|
||||||
// 引数ありコンストラクタ
|
|
||||||
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 void output() {
|
|
||||||
System.out.println(this.idEmployee);
|
|
||||||
System.out.println(this.nmEmployee);
|
|
||||||
System.out.println(this.knEmployee);
|
|
||||||
System.out.println(this.mailAddress);
|
|
||||||
System.out.println(this.password);
|
|
||||||
System.out.println(this.idDepartment);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getIdEmployee() + "\t"
|
|
||||||
+ getNmEmployee() + "\t"
|
|
||||||
+ getKnEmployee() + "\t"
|
|
||||||
+ getMailAddress() + "\t"
|
|
||||||
+ getPassword() + "\t"
|
|
||||||
+ getIdDepartment();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMatchId(String id) {
|
|
||||||
return id.equals(this.idEmployee);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getIdEmployee() {
|
|
||||||
return idEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdEmployee(String idEmployee) {
|
|
||||||
|
|
||||||
if (idEmployee == null) {
|
|
||||||
System.out.println("社員IDが空のため設定できませんでした");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idEmployee.trim().length() == 0) {
|
|
||||||
System.out.println("社員IDが空のため設定できませんでした");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.idEmployee = idEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNmEmployee() {
|
|
||||||
return nmEmployee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNmEmployee(String nmEmployee) {
|
|
||||||
|
|
||||||
if (nmEmployee == null) {
|
|
||||||
System.out.println("社員名が空のため設定できませんでした");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nmEmployee.trim().length() == 0) {
|
|
||||||
System.out.println("社員名が空のため設定できませんでした");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toCSV() {
|
|
||||||
|
|
||||||
return getIdEmployee() + ","
|
|
||||||
+ getNmEmployee() + ","
|
|
||||||
+ getKnEmployee() + ","
|
|
||||||
+ getMailAddress() + ","
|
|
||||||
+ getPassword() + ","
|
|
||||||
+ getIdDepartment();
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getPrimaryKeyValue() {
|
|
||||||
|
|
||||||
return getIdEmployee();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getEmpCount() {
|
|
||||||
return empCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
public class Item {
|
|
||||||
|
|
||||||
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
private String name;
|
|
||||||
private int price;
|
|
||||||
private int stock;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sell(int amount) {
|
|
||||||
//this.stock = this.stock - amount;
|
|
||||||
this.setStock(this.getStock() - amount);
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getName() + " " + getPrice() + "円 (残り" + getStock() + "個)";
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public int totalPrice(){
|
|
||||||
return this.price * this.stock
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,239 +0,0 @@
|
|||||||
import java.util.Scanner;
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
|
|
||||||
EmployeeData employee = new EmployeeData();
|
|
||||||
|
|
||||||
employee.setIdEmployee("10000");
|
|
||||||
employee.setNmEmployee("山田龍也");
|
|
||||||
employee.setKnEmployee("ヤマダタツヤ");
|
|
||||||
employee.setMailAddress("yamada@hoge.jp");
|
|
||||||
employee.setPassword("aaa");
|
|
||||||
employee.setIdDepartment("10");
|
|
||||||
|
|
||||||
// employee.output();
|
|
||||||
// employee.showInfo();
|
|
||||||
System.out.println(employee.toCSV());
|
|
||||||
|
|
||||||
System.out.println(employee.getPrimaryKeyValue());
|
|
||||||
/* 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");
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
BaseData employee0 = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
|
||||||
BaseData employee1 = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
|
|
||||||
BaseData employee2 = new EmployeeData("10002", "麻枝史明 ", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
|
|
||||||
BaseData employee3 = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
|
|
||||||
BaseData employee4 = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "13");
|
|
||||||
|
|
||||||
BaseData[] employees = {
|
|
||||||
employee0,
|
|
||||||
employee1,
|
|
||||||
employee2,
|
|
||||||
employee3,
|
|
||||||
employee4
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < employees.length; i++) {
|
|
||||||
System.out.println(employees[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("現在の社員データ件数:" + EmployeeData.getEmpCount() + "件");
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
for(int i= 0;i < employees.length; i++) {
|
|
||||||
employees[i].showInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("10002 を検索します");
|
|
||||||
System.out.println(employees[2].isMatchId("10002"));
|
|
||||||
|
|
||||||
System.out.println("99999 を検索します");
|
|
||||||
System.out.println(employees[2].isMatchId("99999"));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// System.out.println("検索したい社員IDを入力してください");
|
|
||||||
// Scanner sc = new Scanner(System.in);
|
|
||||||
|
|
||||||
// String searchId = sc.nextLine();
|
|
||||||
// boolean found = false;
|
|
||||||
|
|
||||||
// for (int i = 0; i < employees.length; i++) {
|
|
||||||
|
|
||||||
// if (employees[i].isMatchId(searchId)) {
|
|
||||||
|
|
||||||
// employees[i].showInfo();
|
|
||||||
|
|
||||||
// found = true;
|
|
||||||
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!found) {
|
|
||||||
// System.out.println("該当する社員が見つかりませんでした");
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//5段階目
|
|
||||||
BaseData[] employees = new BaseData[5];
|
|
||||||
|
|
||||||
employees[0] = new EmployeeData(
|
|
||||||
"10000",
|
|
||||||
"山田龍也",
|
|
||||||
"ヤマダタツヤ",
|
|
||||||
"yamada@hoge.jp",
|
|
||||||
"aaa",
|
|
||||||
"10"
|
|
||||||
);
|
|
||||||
|
|
||||||
employees[1] = new EmployeeData(
|
|
||||||
"10001",
|
|
||||||
"高橋準",
|
|
||||||
"タカハシジュン",
|
|
||||||
"jtaka@hoge.jp",
|
|
||||||
"bbb",
|
|
||||||
"10"
|
|
||||||
);
|
|
||||||
|
|
||||||
employees[2] = new EmployeeData(
|
|
||||||
"10002",
|
|
||||||
"麻枝史明",
|
|
||||||
"ヤマダタツヤ",
|
|
||||||
"fmak@hoge.jp",
|
|
||||||
"ccc",
|
|
||||||
"11"
|
|
||||||
);
|
|
||||||
|
|
||||||
employees[3] = new EmployeeData(
|
|
||||||
"10003",
|
|
||||||
"丸戸章介",
|
|
||||||
"マルトショウスケ",
|
|
||||||
"marusyo@hoge.jp",
|
|
||||||
"ddd",
|
|
||||||
"12"
|
|
||||||
);
|
|
||||||
|
|
||||||
employees[4] = new EmployeeData(
|
|
||||||
"10004",
|
|
||||||
"三宅武",
|
|
||||||
"ミヤケタケシ",
|
|
||||||
"miya@hoge.jp",
|
|
||||||
"eee",
|
|
||||||
"13"
|
|
||||||
);
|
|
||||||
|
|
||||||
System.out.println("検索したい社員IDを入力してください");
|
|
||||||
Scanner sc = new Scanner(System.in);
|
|
||||||
|
|
||||||
String searchId = sc.nextLine();
|
|
||||||
boolean found = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < employees.length; i++) {
|
|
||||||
|
|
||||||
if(employees[i].getPrimaryKeyValue().equals(searchId)) {
|
|
||||||
|
|
||||||
System.out.println(employees[i].toString());
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
System.out.println("該当する社員が見つかりませんでした");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6段階目
|
|
||||||
BaseData[] allData = new BaseData[11];
|
|
||||||
|
|
||||||
for (int i = 0; i < employees.length; i++) {
|
|
||||||
allData[i] = employees[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DepartmentData dept1 = new DepartmentData();
|
|
||||||
dept1.setIdDepartment("10");
|
|
||||||
dept1.setNmDepartment("役員");
|
|
||||||
allData[5] = dept1;
|
|
||||||
|
|
||||||
DepartmentData dept2 = new DepartmentData();
|
|
||||||
dept2.setIdDepartment("11");
|
|
||||||
dept2.setNmDepartment("人事・総務部");
|
|
||||||
allData[6] = dept2;
|
|
||||||
|
|
||||||
DepartmentData dept3 = new DepartmentData();
|
|
||||||
dept3.setIdDepartment("12");
|
|
||||||
dept3.setNmDepartment("経理部");
|
|
||||||
allData[7] = dept3;
|
|
||||||
|
|
||||||
DepartmentData dept4 = new DepartmentData();
|
|
||||||
dept4.setIdDepartment("13");
|
|
||||||
dept4.setNmDepartment("システム開発事業部");
|
|
||||||
allData[8] = dept4;
|
|
||||||
|
|
||||||
DepartmentData dept5 = new DepartmentData();
|
|
||||||
dept5.setIdDepartment("14");
|
|
||||||
dept5.setNmDepartment("教育事業部");
|
|
||||||
allData[9] = dept5;
|
|
||||||
|
|
||||||
DepartmentData dept6 = new DepartmentData();
|
|
||||||
dept6.setIdDepartment("15");
|
|
||||||
dept6.setNmDepartment("営業企画部");
|
|
||||||
allData[10] = dept6;
|
|
||||||
|
|
||||||
for (BaseData data : allData) {
|
|
||||||
System.out.println(data.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
public class Shape {
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public Shape(String name) {
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public double area() {
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showInfo() {
|
|
||||||
System.out.println(this.name + "の面積は" + this.area() + "です");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
public class Student {
|
|
||||||
int studentId;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
public void printProfile() {
|
|
||||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Student(int studentId, String name) {
|
|
||||||
this.studentId = studentId;
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
studentCount++;
|
|
||||||
|
|
||||||
}
|
|
||||||
static int studentCount = 0;
|
|
||||||
|
|
||||||
public static int getStudentCount() {
|
|
||||||
return studentCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
public class EmployeeData {
|
|
||||||
String idEmployee;
|
|
||||||
String nmEmployee;
|
|
||||||
String knEmployee;
|
|
||||||
String mailAddress;
|
|
||||||
String password;
|
|
||||||
String idDepartment;
|
|
||||||
/*
|
|
||||||
public void output() {
|
|
||||||
System.out.println(this.idEmployee);
|
|
||||||
System.out.println(this.nmEmployee);
|
|
||||||
System.out.println(this.knEmployee);
|
|
||||||
System.out.println(this.mailAddress);
|
|
||||||
System.out.println(this.password);
|
|
||||||
System.out.println(this.idDepartment);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public void showInfo() {
|
|
||||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee + this.knEmployee +"\t" + this.mailAddress + "\t" + this.password + "\t" + this.idDepartment );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMatchId(String id) {
|
|
||||||
return id.equals(this.idEmployee);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
78
Main.java
78
Main.java
@@ -1,78 +0,0 @@
|
|||||||
import java.util.Scanner;
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
/*
|
|
||||||
EmployeeData employee = new EmployeeData();
|
|
||||||
employee.idEmployee = "10000";
|
|
||||||
employee.nmEmployee = "山田龍也";
|
|
||||||
employee.knEmployee = "ヤマダタツヤ";
|
|
||||||
employee.mailAddress = "yamada@hoge.jp";
|
|
||||||
employee.password = "aaa";
|
|
||||||
employee.idDepartment = "10";
|
|
||||||
*/
|
|
||||||
// employee.output();
|
|
||||||
// employee.showInfo();
|
|
||||||
|
|
||||||
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].idEmployee = "10000";
|
|
||||||
employees[0].nmEmployee = "山田龍也";
|
|
||||||
employees[0].knEmployee = "ヤマダタツヤ";
|
|
||||||
employees[0].mailAddress = "yamada@hoge.jp";
|
|
||||||
employees[0].password = "aaa";
|
|
||||||
employees[0].idDepartment = "10";
|
|
||||||
|
|
||||||
employees[1].idEmployee = "10001";
|
|
||||||
employees[1].nmEmployee = "高橋準";
|
|
||||||
employees[1].knEmployee = "タカハシジュン";
|
|
||||||
employees[1].mailAddress = "jtaka@hoge.jp";
|
|
||||||
employees[1].password = "bbb";
|
|
||||||
employees[1].idDepartment = "10";
|
|
||||||
|
|
||||||
employees[2].idEmployee = "10002";
|
|
||||||
employees[2].nmEmployee = "麻枝史明";
|
|
||||||
employees[2].knEmployee = "ヤマダタツヤ";
|
|
||||||
employees[2].mailAddress = "fmak@hoge.jp";
|
|
||||||
employees[2].password = "ccc";
|
|
||||||
employees[2].idDepartment = "11";
|
|
||||||
|
|
||||||
employees[3].idEmployee = "10003";
|
|
||||||
employees[3].nmEmployee = "丸戸章介";
|
|
||||||
employees[3].knEmployee = "マルトショウスケ";
|
|
||||||
employees[3].mailAddress = "marusyo@hoge.jp";
|
|
||||||
employees[3].password = "ddd";
|
|
||||||
employees[3].idDepartment = "12";
|
|
||||||
|
|
||||||
employees[4].idEmployee = "10004";
|
|
||||||
employees[4].nmEmployee = "三宅武";
|
|
||||||
employees[4].knEmployee = "ミヤケタケシ";
|
|
||||||
employees[4].mailAddress = "miya@hoge.jp";
|
|
||||||
employees[4].password = "eee";
|
|
||||||
employees[4].idDepartment = "13";
|
|
||||||
|
|
||||||
for(int i= 0;i < employees.length; i++) {
|
|
||||||
employees[i].showInfo();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
System.out.println("10002 を検索します");
|
|
||||||
System.out.println(employees[2].isMatchId("10002"));
|
|
||||||
|
|
||||||
System.out.println("99999 を検索します");
|
|
||||||
System.out.println(employees[2].isMatchId("99999"));
|
|
||||||
*/
|
|
||||||
System.out.println("検索したい社員IDを入力してください");
|
|
||||||
Scanner sc = new Scanner(System.in);
|
|
||||||
String str = sc.nextLine();
|
|
||||||
System.out.println("");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
|
public abstract class BaseData{
|
||||||
public abstract class BaseData {
|
|
||||||
|
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
public abstract String toCSV();
|
public abstract String toCSV();
|
||||||
public abstract String getPrimaryKeyValue();
|
public abstract String getPrimaryKeyValue();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
28
src/main/java/BasicCheck1.java
Normal file
28
src/main/java/BasicCheck1.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
public class BasicCheck1 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
Book book = new Book();
|
||||||
|
Book book1 = new Book();
|
||||||
|
|
||||||
|
book.title = "吾輩は猫である";
|
||||||
|
book.author = "夏目漱石";
|
||||||
|
book.price = 800;
|
||||||
|
|
||||||
|
System.out.println(book1.title);
|
||||||
|
System.out.println(book1.author);
|
||||||
|
System.out.println(book1.price);
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(book.title);
|
||||||
|
System.out.println(book.author);
|
||||||
|
System.out.println(book.price);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
19
src/main/java/BasicCheck2.java
Normal file
19
src/main/java/BasicCheck2.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
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("現在の生徒数: " + student1.getStudentCount() + "人");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,35 +4,33 @@ public class BasicCheck3 {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
Item[] items = new Item[3];
|
Item[] items = new Item[3];
|
||||||
items[0] = new Item();
|
|
||||||
items[1] = new Item();
|
|
||||||
items[2] = new Item();
|
|
||||||
|
|
||||||
|
items[0] = new Item();
|
||||||
items[0].setName("ノート");
|
items[0].setName("ノート");
|
||||||
items[0].setPrice(120);
|
items[0].setPrice(120);
|
||||||
items[0].setStock(50);
|
items[0].setStock(50);
|
||||||
|
|
||||||
|
|
||||||
|
items[1] = new Item();
|
||||||
items[1].setName("消しゴム");
|
items[1].setName("消しゴム");
|
||||||
items[1].setPrice(80);
|
items[1].setPrice(80);
|
||||||
items[1].setStock(30);
|
items[1].setStock(30);
|
||||||
|
|
||||||
|
|
||||||
|
items[2] = new Item();
|
||||||
items[2].setName("鉛筆");
|
items[2].setName("鉛筆");
|
||||||
items[2].setPrice(60);
|
items[2].setPrice(60);
|
||||||
items[2].setStock(100);
|
items[2].setStock(100);
|
||||||
|
|
||||||
for(int i=0;i < items.length;i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
items[i].sell(5);
|
items[i].sell(5);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
System.out.println(items[i]);
|
||||||
for(int i = 0;i < items.length;i++) {
|
|
||||||
System.out.println(items[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
18
src/main/java/Book.java
Normal file
18
src/main/java/Book.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
public class Book {
|
||||||
|
String title;
|
||||||
|
String author;
|
||||||
|
int price;
|
||||||
|
|
||||||
|
public Book() {
|
||||||
|
title = "タイトル未設定";
|
||||||
|
author = "著者未設定";
|
||||||
|
price = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Book(String title,String author,int price) {
|
||||||
|
this.title = title;
|
||||||
|
this.author = author;
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
}
|
||||||
142
src/main/java/EmployeeData.java
Normal file
142
src/main/java/EmployeeData.java
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
public class EmployeeData extends BaseData {
|
||||||
|
|
||||||
|
private String idEmployee;
|
||||||
|
private String nmEmployee;
|
||||||
|
private String knEmployee;
|
||||||
|
private String mailAddress;
|
||||||
|
private String password;
|
||||||
|
private String idDepartment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static int empCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getIdEmployee() {
|
||||||
|
return idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdEmployee(String idEmployee) {
|
||||||
|
if (idEmployee == null || idEmployee == " " ||idEmployee == " " || idEmployee.isEmpty()) {
|
||||||
|
System.out.println("社員IDが空のため設定できませんでした");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.idEmployee = idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmEmployee() {
|
||||||
|
return nmEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setNmEmployee(String nmEmployee) {
|
||||||
|
if (nmEmployee == null || nmEmployee == " " || nmEmployee == " " || nmEmployee.isEmpty()){
|
||||||
|
System.out.println("社員名が空のため設定できませんでした");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 boolean isMatchId(String id) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (this.idEmployee != null && this.idEmployee.equals(id)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showInfo() {
|
||||||
|
System.out.println(this.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return(getIdEmployee() + "\t" + getNmEmployee() + "\t" + getKnEmployee() + "\t" + getMailAddress() + "\t" +getPassword() + "\t" +getIdDepartment()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int getEmpCount() {
|
||||||
|
return empCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toCSV() {
|
||||||
|
return getIdEmployee() + "," + getNmEmployee() + "," + getKnEmployee() + "," + getMailAddress() + "," + getPassword() + "," + getIdDepartment();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryKeyValue(){
|
||||||
|
return this.idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
56
src/main/java/Item.java
Normal file
56
src/main/java/Item.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
class Item {
|
||||||
|
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int price;
|
||||||
|
private int stock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void sell(int amount) {
|
||||||
|
this.setStock(this.getStock() - amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName() + " " + getPrice() + "円 (残り" + getStock() + "個)";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
73
src/main/java/Main.java
Normal file
73
src/main/java/Main.java
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
BaseData[] employees = new BaseData[5];
|
||||||
|
|
||||||
|
|
||||||
|
employees[0] = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10");
|
||||||
|
employees[1] = new EmployeeData("10001", "高橋準", "タカハシジュン", "jtaka@hoge.jp", "bbb", "10");
|
||||||
|
employees[2] = new EmployeeData("10002", "麻枝史明", "マエダフミアキ", "fmak@hoge.jp", "ccc", "11");
|
||||||
|
employees[3] = new EmployeeData("10003", "丸戸章介", "マルトショウスケ", "marusyo@hoge.jp", "ddd", "12");
|
||||||
|
employees[4] = new EmployeeData("10004", "三宅武", "ミヤケタケシ", "miya@hoge.jp", "eee", "13");
|
||||||
|
|
||||||
|
for (int i = 0; i < employees.length; i++) {
|
||||||
|
|
||||||
|
//System.out.println(employees[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("現在のデータ件数:"+EmployeeData.getEmpCount()+"件");
|
||||||
|
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Scannerを使って、
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
//「検索したい社員IDを入力してください」と表示し
|
||||||
|
System.out.println("検索したい社員IDを入力してください(終了する場合は0)");
|
||||||
|
//キーボード入力を受け取る
|
||||||
|
String idEmployee = scanner.next();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ("0".equals(idEmployee)) {
|
||||||
|
System.out.println("システムを終了します");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//employees配列をfor文で1件ずつ確認し
|
||||||
|
for(int i = 0; i < employees.length; i++) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (((EmployeeData) employees[i]).isMatchId(idEmployee)) {
|
||||||
|
//一致する社員が見つかったら、その社員のshowInfoメソッドを呼び出す
|
||||||
|
((EmployeeData) employees[i]).showInfo();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
System.out.println("検索したいIDが見つかりませんでした");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//System.out.println(employees[0].toCSV());
|
||||||
|
//System.out.println(employees[0].getPrimaryKeyValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
src/main/java/Student.java
Normal file
30
src/main/java/Student.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
public class Student {
|
||||||
|
|
||||||
|
int studentId;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
|
||||||
|
public void printProfile() {
|
||||||
|
System.out.println("学籍番号:"+this.studentId+" 名前:"+this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Student(int StudentId,String name) {
|
||||||
|
|
||||||
|
this.studentId = StudentId;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
studentCount++;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getStudentCount() {
|
||||||
|
return studentCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int studentCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user