2日目段階1です
This commit is contained in:
@@ -2,17 +2,16 @@
|
|||||||
public class BasicCheck1 {
|
public class BasicCheck1 {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
|
||||||
|
|
||||||
Book book = new Book();
|
Book book1 = new Book();
|
||||||
|
Book book2 = new Book("銀河鉄道の夜", "宮沢賢治", 500);
|
||||||
|
|
||||||
book.title = "吾輩は猫である";
|
// book.title = "吾輩は猫である";
|
||||||
book.author = "夏目漱石";
|
// book.author = "夏目漱石";
|
||||||
book.price = 800;
|
// book.price = 800;
|
||||||
|
|
||||||
System.out.println(book.title);
|
System.out.println(book1.title +"\n"+ book1.author +"\n"+ book1.price);
|
||||||
System.out.println(book.author);
|
System.out.println(book2.title +"\n"+ book2.author +"\n"+ book2.price);
|
||||||
System.out.println(book.price);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
|
|
||||||
public class Book {
|
public class Book {
|
||||||
String title;
|
public String title;
|
||||||
String author;
|
public String author;
|
||||||
int price;
|
public 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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user