I think you mean you're unable to transition from the pattern of asking for data, responding with results. So for Problem 1, there is no input required. The program simply outputs the book with the...
Type: Posts; User: GregBrannon
I think you mean you're unable to transition from the pattern of asking for data, responding with results. So for Problem 1, there is no input required. The program simply outputs the book with the...
Great! Glad it worked, and good job figuring out the bs. part. I wasn't sure what object the method was being called on, and I forgot to mention it.
Where do you try to call searchForPrice()?
I would think the code you posted might look like:
String Price = JOptionPane.showInputDialog(null,
"Enter a Price ");
results =...
Remove this: "ArrayList<Book>" from that line. You don't re-declare results, just change its value(s).
Your second attempt seems correct to me, though I'm not sure why the method doesn't expect a double parameter for the max book price. Does it work?
You're right. To use methods specific to ArrayList, those not included in List, will require casting library to an ArrayList. A bit of a pain. Which should you use? Whichever you prefer. ...
Yes, or it can all be done in one line (but I'd normally initialize in the constructor):
private List<Book> library = new ArrayList<Book>();
You will find it recommended to abstract the details of the implementation by using the following approach:
// declaration
List<Book> library;
// initialization
library = new ArrayList<Book>();