hein stept 5 done
This commit is contained in:
12
em-oop/src/BasicCheck2.java
Normal file
12
em-oop/src/BasicCheck2.java
Normal file
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
31
em-oop/src/BasicCheck3.java
Normal file
31
em-oop/src/BasicCheck3.java
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
public class BasicCheck3 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
Item []items = new Item[3];
|
||||
|
||||
items[0]= new Item();
|
||||
items[0].name = "ノート";
|
||||
items[0].price = 120;
|
||||
items[0].stock = 50;
|
||||
|
||||
items[1] = new Item();
|
||||
items[1].name = "消しゴム";
|
||||
items[1].price = 80;
|
||||
items[1].stock = 30;
|
||||
|
||||
items[2] = new Item();
|
||||
items[2].name = "鉛筆";
|
||||
items[2].price = 60;
|
||||
items[2].stock = 100;
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i].sell(5);
|
||||
System.out.println(items[i].name + " " + items[i].price + "円 残り" + items[i].stock + "個");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
14
em-oop/src/EmployeeData.java
Normal file
14
em-oop/src/EmployeeData.java
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
public class EmployeeData {
|
||||
String idEmployee;
|
||||
String nmEmployee;
|
||||
String knEmployee;
|
||||
String mailAddress;
|
||||
String password;
|
||||
String idDepartment;
|
||||
|
||||
void showInfo() {
|
||||
System.out.println(this.idEmployee + "\t" + this.nmEmployee + this.knEmployee+this.mailAddress+this.password+this.idDepartment);
|
||||
}
|
||||
|
||||
}
|
||||
12
em-oop/src/Item.java
Normal file
12
em-oop/src/Item.java
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
public class Item {
|
||||
String name;
|
||||
int price;
|
||||
int stock;
|
||||
|
||||
|
||||
void sell(int amount) {
|
||||
this.stock = this.stock - amount;
|
||||
}
|
||||
|
||||
}
|
||||
27
em-oop/src/Main.java
Normal file
27
em-oop/src/Main.java
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
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.showInfo();
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
em-oop/src/Student.java
Normal file
13
em-oop/src/Student.java
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
public class Student {
|
||||
|
||||
|
||||
int studentId;
|
||||
String name;
|
||||
void printProfile() {
|
||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user