段階1完了しました。

This commit is contained in:
2026-09-15 12:57:23 +09:00
parent eda72f9f06
commit d7c1f2b251
2 changed files with 21 additions and 7 deletions

View File

@@ -3,13 +3,15 @@ public class BasicCheck1 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ // TODO 自動生成されたメソッド・スタブ
Book book = new Book(); Book book1 = new Book();
book.title = "吾輩は猫である"; System.out.println(book1.title);
book.author = "夏目漱石"; System.out.println(book1.author);
book.price = 800; System.out.println(book1.price);
System.out.println(book.title);
System.out.println(book.author); Book book2 = new Book("銀河鉄道の夜","宮沢賢治",500);
System.out.println(book.price); System.out.println(book2.title);
System.out.println(book2.author);
System.out.println(book2.price);
} }
} }

View File

@@ -3,4 +3,16 @@ public class Book {
String title; String title;
String author; String author;
int price; int price;
public Book () {
title = "タイトル未設定";
author = "著者未設定";
price = 0;
}
public Book(String title,String author,int price) {
this.title = title;
this.author = author;
this.price = price;
}
} }