This commit is contained in:
2026-10-14 17:38:57 +09:00
parent 7e61a24d20
commit d656d3c5a8
11 changed files with 119 additions and 1 deletions

6
.classpath Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build/

23
.project Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>em-oop</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="21"/>
</faceted-project>

View File

@@ -1,5 +1,5 @@
public class em_oop_kawara {
public class BasicCheck1 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ

View File

@@ -0,0 +1,13 @@
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,35 @@
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);
}
for (int i = 0; i < items.length; i++) {
System.out.println(items[i].name + " 価格:" + items[i].price + "円 在庫:" + items[i].stock );
}
}
}

6
src/main/java/Book.java Normal file
View File

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

10
src/main/java/Item.java Normal file
View File

@@ -0,0 +1,10 @@
public class Item {
String name;
int price;
int stock;
public void sell(int amount) {
this.stock = this.stock - amount;
}
}

View File

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