1段階目終わりました

This commit is contained in:
2026-09-15 14:30:41 +09:00
parent 29cf120dbf
commit 2cc3a84a2d
2 changed files with 27 additions and 8 deletions

View File

@@ -3,13 +3,15 @@ public class BasicCheck1 {
public static void main(String[] args) {
Book book = new Book();
String title = "吾輩は猫である";
String author = "夏目礎石";
int price = 800;
System.out.println(title);
System.out.println(author);
System.out.println(price);
Book book1 = new Book();
Book book2 = new Book("銀河鉄道の夜", "宮沢賢治", 500);
System.out.println(book1.title + "\n" + book1.author + "\n" + book1.price);
System.out.println(book2.title + "\n" + book2.author + "\n" + book2.price);
}

View File

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