私はかなり新しく、Java
使用してBlueJ
います。エラーが発生し続けます:
incompatible types
自明のように聞こえますが、問題を解決する方法がわかりません。誰かが私を助けてくれることを願っています。前もって感謝します。
へのコードは次のclass Program2
とおりです。
import java.util.*;
public class Program2 {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
Catalog store = new Catalog(3);
int itemnum;
Item item;
try {
store.insert
(new Music(1111, "Gold", 12.00, "Abba"));
store.insert
(new Movie(2222, "Mamma Mia", 16.00, "Meryl Streep"));
store.insert
(new Book(3333, "DaVinci Code", 8.00, "Dan Brown"));
store.insert
(new Music(4444, "Legend", 15.00, "Bob Marley"));
} catch (CatalogFull exc) {
System.out.println(exc);
}
// Insert code here to perform a sequence of
// interactive transactions with the user.
// The user enters an item number and the program
// either displays the item or prints an error message
// if the item is not found. The program terminates
// when the user enters zero as the item number.
while (!item.equals("0")) {
item = store.find(itemnum);
if (item != null) {
System.out.print(itemnum);
} else {
System.out.printf("%s was not found.%n", item);
}
System.out.println();
System.out.print("Player (0 to exit)? ");
itemnum = kbd.next(); //Error on "()"
}
}
}