段階1です
This commit is contained in:
@@ -4,13 +4,23 @@ 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.author);
|
||||||
|
// System.out.println(book.price);
|
||||||
|
book.title = "タイトル未設定";
|
||||||
|
book.author = "著者未設定";
|
||||||
|
book.price = 0;
|
||||||
|
|
||||||
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);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
Book book2 = new Book("銀河鉄道の夜","宮沢賢治",500);
|
||||||
|
System.out.println(book2.title);
|
||||||
|
System.out.println(book2.author);
|
||||||
|
System.out.println(book2.price);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,13 @@ public class Book {
|
|||||||
String title;
|
String title;
|
||||||
String author;
|
String author;
|
||||||
int price;
|
int price;
|
||||||
|
|
||||||
|
public Book() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Book(String title, String author, int price) {
|
||||||
|
this.title = title;
|
||||||
|
this.author = author;
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user