Compare commits
1 Commits
769fb977ca
...
s-ohashi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b2f0a60d0 |
@@ -3,10 +3,13 @@ public class BasicCheck1 {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
Book book = new Book();
|
Book book = new Book();
|
||||||
|
|
||||||
book.title = "吾輩は猫である";
|
book.title = "吾輩は猫である";
|
||||||
book.author = "夏目漱石";
|
book.author = "夏目漱石";
|
||||||
book.price = 800;
|
book.price = 800;
|
||||||
|
|
||||||
System.out.println(book.title);
|
System.out.println(book.title);
|
||||||
System.out.println(book.author);
|
System.out.println(book.author);
|
||||||
System.out.println(book.price);
|
System.out.println(book.price);
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck2 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Student student = new Student();
|
|
||||||
student.studentId = 1;
|
|
||||||
student.name = "鈴木一郎";
|
|
||||||
student.printProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
public class BasicCheck3 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
Item[] items = new Item[3];
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
items[i] = new Item();
|
|
||||||
}
|
|
||||||
items[0].name = "ノート";
|
|
||||||
items[0].price = 120;
|
|
||||||
items[0].stock = 50;
|
|
||||||
items[1].name = "消しゴム";
|
|
||||||
items[1].price = 80;
|
|
||||||
items[1].stock = 30;
|
|
||||||
items[2].name = "鉛筆";
|
|
||||||
items[2].price = 60;
|
|
||||||
items[2].stock = 100;
|
|
||||||
|
|
||||||
for (Item i : items) {
|
|
||||||
i.sell(5);
|
|
||||||
System.out.println(i.name + " " + i.price + "円 残り" + i.stock + "個 合計金額" + i.totalPrice() + "円");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
public class Item {
|
|
||||||
String name;
|
|
||||||
int price;
|
|
||||||
int stock;
|
|
||||||
|
|
||||||
void sell(int amount) {
|
|
||||||
this.stock -= amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalPrice() {
|
|
||||||
return this.price * this.stock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
public class Student {
|
|
||||||
int studentId;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
void printProfile() {
|
|
||||||
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user