diff --git a/em-oop/src/BasicCheck1.java b/em-oop/src/BasicCheck1.java index ffe91ae..6d214fb 100644 --- a/em-oop/src/BasicCheck1.java +++ b/em-oop/src/BasicCheck1.java @@ -3,7 +3,14 @@ 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); } - + + } diff --git a/em-oop/src/BasicCheck2.java b/em-oop/src/BasicCheck2.java new file mode 100644 index 0000000..ac2889a --- /dev/null +++ b/em-oop/src/BasicCheck2.java @@ -0,0 +1,12 @@ + +public class BasicCheck2 { + + public static void main(String[] args) { + // TODO 自動生成されたメソッド・スタブ + Student student = new Student(); + student.studentId = 1; + student.name = "鈴木一郎"; + + student.printProfile(); + } +} \ No newline at end of file diff --git a/em-oop/src/BasicCheck3.java b/em-oop/src/BasicCheck3.java new file mode 100644 index 0000000..346c588 --- /dev/null +++ b/em-oop/src/BasicCheck3.java @@ -0,0 +1,13 @@ + +public class BasicCheck3 { + public static void main(String[] args) { + Item[] items = new Item[3]; + items[0] = new Item("ノート", 120, 50); + items[1] = new Item("消しゴム", 80, 30); + items[2] = new Item("鉛筆", 60, 100); + + for (int i = 0; i < 3; i++) { + items[i].sell(5); + } + } +} diff --git a/em-oop/src/Book.java b/em-oop/src/Book.java index 90f3238..418f4a3 100644 --- a/em-oop/src/Book.java +++ b/em-oop/src/Book.java @@ -1,4 +1,6 @@ public class Book { - + String title; + String author; + int price; } diff --git a/em-oop/src/EmployeeData.java b/em-oop/src/EmployeeData.java new file mode 100644 index 0000000..f2b727f --- /dev/null +++ b/em-oop/src/EmployeeData.java @@ -0,0 +1,39 @@ + +public class EmployeeData { + String idEmployee; + String nmEmployee; + String knEmployee; + String mailAddress; + String password; + String idDepartment; + + public EmployeeData(String idEmployee, String nmEmployee, String knEmployee, String mailAddress, String password, + String idDepartment) { + this.idEmployee = idEmployee; + this.nmEmployee = nmEmployee; + this.knEmployee = knEmployee; + this.mailAddress = mailAddress; + this.password = password; + this.idDepartment = idDepartment; + } + public void showInfo() { + 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 EmployeeData(String idEmployee) { +// this.idEmployee = idEmployee; +// public EmployeeData(String nmEmployee) { +// this.idEmployee = idEmployee; +// this.nmEmployee = nmEmployee; +// this.knEmployee = knEmployee; +// this.mailAddress = mailAddress; +// this.password = password; +// this.idDepartment = idDepartment; +// } +} diff --git a/em-oop/src/Item.java b/em-oop/src/Item.java new file mode 100644 index 0000000..339edc1 --- /dev/null +++ b/em-oop/src/Item.java @@ -0,0 +1,18 @@ + +public class Item { + String name; + int price; + int stock; + + public Item(String name, int price, int stock) { + this.name = name; + this.price = price; + this.stock = stock; + } + + public void sell(int amount) { + this.stock = this.stock - amount; + System.out.println(name + price +"円 残り"+this.stock + "個"); + } + +} diff --git a/em-oop/src/Main.java b/em-oop/src/Main.java new file mode 100644 index 0000000..615e5dc --- /dev/null +++ b/em-oop/src/Main.java @@ -0,0 +1,11 @@ + +public class Main { + public static void main(String[] args) { + //EmployeeData[] employee = new EmployeeData[5]; + EmployeeData employee = new EmployeeData("10000", "山田龍也", "ヤマダタツヤ", "yamada@hoge.jp", "aaa", "10"); + + employee.showInfo(); + } + + +} diff --git a/em-oop/src/Student.java b/em-oop/src/Student.java new file mode 100644 index 0000000..60ab5f6 --- /dev/null +++ b/em-oop/src/Student.java @@ -0,0 +1,8 @@ +public class Student { + int studentId; + String name; + + void printProfile() { + System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name); + } +} \ No newline at end of file