-1
public class Book {
//variables
private String title = "";
int isbn = 0;
int quantity = 0;
public Book(String title, int isbn, int quantity) throws Exception {
this.setTitle(title);
this.setIsbn(isbn);
this.setQuantity(quantity);
}
//toString method that return with book information
public String toString() {
String s = "";
s = "title:" + this.title;
s = s + "\nIsbn:" + this.isbn;
s = s + "\nQuantity:" + this.quantity;
return s;
}
public void setTitle(String newTitle) throws Exception {
if ((newTitle != null)) {
this.title = newTitle;
} else {
BookException be = new BookException();
be.setMessage("wrong input, title should not be blank.");
throw be;
}
}
public String getTitle() {
return this.title;
}
}
warum es gab kein Symbol im Code this.setIsbn(isbn)
und this.setQuantity(quantity)
Fix kann nicht Symbol in öffentlichen Klasse java
Wo haben Sie die Methoden 'setIsbn' und' setQuantity'? –