The method definition LibraryBook
is a void method, but it does not have void
in the head of its definition. Why does it not cause error? I try another method definition and the other really causes error: invalid method declaration
.
/**
/The following is a definition of the LibraryBook class.
/This class has four instance variables and one static (or class) variable.
/One of the instance variables is a type Author.
**/
public class LibraryBook
{
private int bookId;
private String bookName;
private Author bookAuthor;
private double bookPrice;
private static double totalInvValue;
public LibraryBook (int id, String name, Author author, double price)
{
bookId = id;
bookName = name;
bookAuthor = author;
bookPrice = price;
totalInvValue += price;
}
public String toString()
{
String response = "";
response += "Book Name is: " + bookName;
response += "\nIt costs: " + bookPrice;
response += "\nIt was " + bookAuthor.toString();
return response;
}
public static double getTotValue()
{
return totalInvValue;
}
}