diff --git a/em-oop/src/BasicCheck1.java b/em-oop/src/BasicCheck1.java index edb41c8..c1b9c30 100644 --- a/em-oop/src/BasicCheck1.java +++ b/em-oop/src/BasicCheck1.java @@ -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); + + + } diff --git a/em-oop/src/Book.java b/em-oop/src/Book.java index 3cacf9e..101a1d3 100644 --- a/em-oop/src/Book.java +++ b/em-oop/src/Book.java @@ -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; + + } + }