这是我的代码完整。我意识到它没有完成,但我有问题的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