25 lines
576 B
Java
25 lines
576 B
Java
|
|
public class Book {
|
|
public String title;
|
|
public String author;
|
|
public int price;
|
|
|
|
//引数なしコンストラクタ
|
|
public Book() {
|
|
this.title = "タイトル未設定";
|
|
this.author = "著者未設定";
|
|
this.price = 0;
|
|
|
|
// System.out.println("コンストラクタが呼び出されました");
|
|
|
|
}
|
|
//引数ありコンストラクタ
|
|
public Book(String title, String author, int price) {
|
|
// System.out.println("引数なしのコンストラクタが呼び出されました");
|
|
this.title = title;
|
|
this.author = author;
|
|
this.price = price;
|
|
}
|
|
|
|
}
|