public static void main(String[] args) {
// create a book named "Java is Fun" with 200 in stock costing 55.00 each. The stock number is 1234
Book javafun = new Book("Java is Fun", 200, 55.00, 1234);
//print out the book using the toString() method
System.out.println (javafun.toString());
//create a book calling the empty constructor.
Book newbook2 = new Book();
//set the title to "Databases R Us"
String title = "Databases R Us";
//set the number in stock to 50
int numInStock = 50;
// set the cost each to $35.00
double cost = 35.00; <------ this
// set the stock number to 5555
int stockNum = 5555;
//print out the book.
System.out.println(newbook2.toString());
//change the price to $55.00
double cost = 55.00; <-- and this gives me duplicate error
//print out the book
System.out.println (newbook2.toString());
}
我該如何做空間下面的步驟?java get missing field
我有點做了我認爲應該但它給了我我有重複。並且輸出不出來正確的
輸出應該是:
Java是有趣的ID號1234在股票200本書的成本每$ 55,00。
ID爲5555的數據庫R Us有50本書,每本價值35美元。
ID爲5555的數據庫R Us有50本書,每本55美元。
變化的價格將只需要'成本= 55.00;'(不包括前面的'double')。對於其他「輸出不正確」,「書」的代碼是必需的。預期產出是多少? – tofi9 2015-02-07 06:56:30
它會幫助我們幫助你,如果你可以提供我們班書。 :D謝謝... – 2015-02-07 07:30:38
[在我的主應用程序中調用setter方法]的可能的重複(http://stackoverflow.com/questions/4603353/calling-setter-methods-in-my-main-application) – Joe 2015-02-07 09:51:48