Can someone help me fix this? After I compile I get ilegal start of expression for the line that says public String getBook(). I cannot see why this is not allowed.
My output should be as follows:
Jane Doe
Long night
12.5
Long Night by Jane Doe
I am supposed to use a toString constructor for this program to produce the above output. My program is as follows:
public class Book{
private String author, title;
private double price;
public Book (String abook){
book = abook;
title = title;
price = 0.0;
public String getBook (){
return book;
}
public String getAuthor(){
return author;
}
public String getTitle(){
return title;
}
public double getPrice (){
return price;
}
public void setBook(String newbook){
book = new book();
}
public String toString( ){
return title + "" + author;
}
Book abook = new Book ("Jane Doe", "Long Night", "12.50");
System.out.println(abook.getAuthor());
System.out.println(abook.getTitle());
System.out.println(abook.getPrice());
System.out.println(abook);
}
}
Thanks for your help.