任何人都可以看到我如何在此代碼上運行主要方法嗎? 我想檢查是否有任何編譯時錯誤或運行時錯誤,但我得到這個錯誤消息「無法找到或加載主類應用程序」。錯誤:無法找到或加載主類應用程序
class Book {
private static int internalID = 0;
private String isbn;
private int myID;
public Book(String isbnP) {
if (isbnP == null) {
throw new IllegalArgumentException("null ISBN not accepted");
}
isbn = isbnP;
myID = internalID++;
}
public String getBookinfo() {
return isbn;
}
public String toString() {
return "<" + myID + "," + isbn + ">";
}
// To Do: Override Object.equals()
// Two objects are equal iff isbn of the two books are same
}
class ComSBook extends Book {
private String category;
public ComSBook(String isbnP, String catP) {
super(isbnP);
category = catP;
}
@override
public String getBookInfo() {
return "ComS " + category + " " + super.getBookinfo();
}
}
class NetworkBook extends ComSBook {
private boolean isWithCD;
public NetworkBook (String isbnP, boolean withCD){
super(isbnP,"Network");
isWithCD = withCD;
}
@override
public String getBookInfo(){
return super.getBookInfo() + " withCD: " + isWithCD;
}
}
class ReviewPolymorp{
public static void main(String[] args){
Book abook = new Book("A-1");
Book bbook = new Book("B-1");
ComSBook csbook = new ComSBook("C-11", "General");
NetworkBook netbook = new NetworkBook("N-11", true);
System.out.println(abook);
System.out.println(bbook);
System.out.println(csbook);
System.out.println(netbook);
abook = csbook;
System.out.println(abook.getBookinfo());
bbook = netbook;
System.out.println(bbook.getBookinfo());
netbook = (NetworkBook) bbook;
System.out.println(netbook.getBookinfo());
netbook = (NetworkBook) csbook;
System.out.println(netbook.getBookinfo());
netbook = csbook;
}
}