So I have the following code contained within a class labeled book.
public void setPublication(int bookVersion, String bookISBN, double bookPrice) {
bookVersion = pub.setVersion(bookVersion);
bookISBN = pub.setISBN(bookISBN);
bookPrice = pub.setPrice(bookPrice);
It refers to the following class, called publication.
//Getter method to get the book ISBN
public String getISBN(String bookISBN){
return ISBN;
}
//Getter method to get the book Version
public int getVersion(int bookVersion){
return version;
}
//Getter method to get the book Price
public double getPrice(double bookPrice){
return price;
}
//Setter method to set the book ISBN
public void setISBN(String bookISBN){
ISBN = bookISBN;
}
//Setter method to set the book Version
public void setVersion(int bookVersion){
version = bookVersion;
}
//Setter method to set the book Price
public void setPrice(double bookPrice){
price = bookPrice;
}
In my driver class I have switches for user input
switch (input)
{
case 'A': //Add Book
System.out.print("Enter book title:\n");
bookTitle = scan.nextLine();
book1.setTitle(bookTitle);
System.out.print("Enter book author:\n");
bookAuthor = scan.nextLine();
book1.setAuthor(bookAuthor);
System.out.print("Enter book version:\n");
bookVersion = Integer.parseInt(scan.nextLine());
System.out.print("Enter book ISBN:\n");
bookISBN = scan.nextLine();
System.out.print("Enter book price:\n");
bookPrice = Double.parseDouble(scan.nextLine());
book1.setPublication(bookVersion, bookISBN, bookPrice);
break;
case 'D': //Display course
System.out.print(book1);
break;
case 'Q': //Quit
break;
case '?': //Display Menu
printMenu();
break;
default:
System.out.print("Unknown action\n");
break;
}
I'm having trouble aggrating the publication class to the book class. This is a homework project, so It would be super helpful if someone could explain it to me rather than just giving me an answer.
I think what needs to happen is the book class has to set the information in the publication class. which is what I was trying to do with
bookVersion = pub.setVersion(bookVersion);
However, it keeps asking me to change the setter method in the publication class so it returns a value.