I have this first method that is supposed to return the title of a book that refers back to the instance variable. This works fine but it makes me select the inserted title instead of using the user inputted title immediately, is there a way for it to return the title without me going through the extra step of selecting the title in a drop down list?
I have a second method that is supposed to return the remaining chapters by finding the different between (BookChapters) and (BookMark), but when I run it it doesn't return the difference and like the first method it makes me choose the remaining chapters in a drop down list.
This is for an introductory programming course, I've tried looking up java documentation on returning mathematical statements but I haven't achieved much.
private String BookTitle;
private int BookChapters;
private int BookMark;
public int RemainingChapters;
// instance variables //
public Textbook()
{
// initialise instance variables
BookTitle = "Lord of the Flies";
BookChapters = 3;
BookMark = 0;
}
// my constructor //
public String getTitle(String BookTitle)
{
return BookTitle;
}
// my first method to return the title of the book //
public int getRemainingChapters (int RemainingChapters)
{
return RemainingChapters = BookChapters - BookMark;
}
// my second method to return the remaining chapters //
https://i.stack.imgur.com/hv7oh.jpg
this image should help me explain my issue regarding the first method