段階4までです

This commit is contained in:
2026-09-15 15:33:43 +09:00
parent e8b163e1b6
commit a52f78be66
8 changed files with 113 additions and 3 deletions

View File

@@ -3,7 +3,14 @@ public class BasicCheck1 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ // 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);
} }
} }

View 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();
}
}

View 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);
}
}
}

View File

@@ -1,4 +1,6 @@
public class Book { public class Book {
String title;
String author;
int price;
} }

View 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
View 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
View 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
View File

@@ -0,0 +1,8 @@
public class Student {
int studentId;
String name;
void printProfile() {
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
}
}