這是我的代碼完整。我意識到它沒有完成,但我有問題的ISBN參數部分。當我編譯時,它說「不兼容類型」突出顯示「返回」不正確的ISBN「;」需要幫助 - 使用int和String的Java if/else語句
class Book{
private String title;
private int ISBN;
private String authorLastName;
private String authorFirstName;
private int yearPublished;
public Book(){
}
public Book(String newTitle, int newISBN, String newAuthorLastName,
String newAuthorFirstName, int newYearPublished){
title = newTitle;
ISBN = newISBN;
authorLastName = newAuthorLastName;
authorFirstName = newAuthorFirstName;
yearPublished = newYearPublished;
}
public String setTitle(String newTitle){
if(title.length()> 3){
return title;
}else{
return "Title too short.";
}
}
public int setISBN(int newISBN){
if((newISBN>=10000) &&(newISBN<=20000)){
return ISBN;
}else{
return "Incorrect ISBN";
}
}
}
如果你們能我將不勝感激!
你知道什麼返回類型和return語句是誰? – 2014-10-01 03:36:10
爲什麼你的'set'方法沒有設置任何東西? – SLaks 2014-10-01 03:37:06