一日目の段階4です。
This commit is contained in:
41
em-oop/src/BasicCheck3.java
Normal file
41
em-oop/src/BasicCheck3.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
public class BasicCheck3 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
Item[] items = new Item[3];
|
||||||
|
|
||||||
|
Item item1 = new Item();
|
||||||
|
|
||||||
|
item1.name = "ノート";
|
||||||
|
item1.price = 120;
|
||||||
|
item1.stock = 50;
|
||||||
|
|
||||||
|
Item item2 = new Item();
|
||||||
|
|
||||||
|
item2.name = "消しゴム";
|
||||||
|
item2.price = 80;
|
||||||
|
item2.stock = 30;
|
||||||
|
|
||||||
|
Item item3 = new Item();
|
||||||
|
|
||||||
|
item3.name = "鉛筆";
|
||||||
|
item3.price = 60;
|
||||||
|
item3.stock = 100;
|
||||||
|
|
||||||
|
items[0] = item1;
|
||||||
|
items[1] = item2;
|
||||||
|
items[2] = item3;
|
||||||
|
|
||||||
|
for(int i = 0; i < items.length; i++) {
|
||||||
|
|
||||||
|
items[i].sell(5);
|
||||||
|
|
||||||
|
System.out.println(items[i].name +" " + items[i].price +"円 " + "残り" +items[i].stock +"個");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
9
em-oop/src/EmployeeData.java
Normal file
9
em-oop/src/EmployeeData.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
public class EmployeeData {
|
||||||
|
String idEmployee;
|
||||||
|
String nmEmployee;
|
||||||
|
String knEmployee;
|
||||||
|
String mailAddress;
|
||||||
|
String password;
|
||||||
|
String idDepartment;
|
||||||
|
}
|
||||||
10
em-oop/src/Item.java
Normal file
10
em-oop/src/Item.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
public class Item {
|
||||||
|
String name;
|
||||||
|
int price;
|
||||||
|
int stock;
|
||||||
|
|
||||||
|
void sell(int amount) {
|
||||||
|
this.stock = this.stock - amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
em-oop/src/Main.java
Normal file
26
em-oop/src/Main.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
System.out.println(employee.idEmployee);
|
||||||
|
System.out.println(employee.nmEmployee);
|
||||||
|
System.out.println(employee.knEmployee);
|
||||||
|
System.out.println(employee.mailAddress);
|
||||||
|
System.out.println(employee.password);
|
||||||
|
System.out.println(employee.idDepartment);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user