段階4までです
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
13
em-oop/src/BasicCheck3.java
Normal file
13
em-oop/src/BasicCheck3.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
public class Book {
|
||||
|
||||
String title;
|
||||
String author;
|
||||
int price;
|
||||
}
|
||||
|
||||
39
em-oop/src/EmployeeData.java
Normal file
39
em-oop/src/EmployeeData.java
Normal file
@@ -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;
|
||||
// }
|
||||
}
|
||||
18
em-oop/src/Item.java
Normal file
18
em-oop/src/Item.java
Normal file
@@ -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 + "個");
|
||||
}
|
||||
|
||||
}
|
||||
11
em-oop/src/Main.java
Normal file
11
em-oop/src/Main.java
Normal file
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
8
em-oop/src/Student.java
Normal file
8
em-oop/src/Student.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class Student {
|
||||
int studentId;
|
||||
String name;
|
||||
|
||||
void printProfile() {
|
||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user