This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm progressing well with my assignment (B&S v2.1.2) and I'm implementing the user interface for searching.
The assignment specification says that
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.
I was thinking abut having a a JTextField (or JComboBox, which stores search history) next to a search button. Searching with no text in the JTextField would return all records, entering a value into the JTextField would search on both the name and location fields (ie, if the value entered matches either the name OR location then the record is returned in the search results).
I'm not sure whether that would meet the requirement. The requirement states searching on name and/or location.
The alternative would be to have a search dialog where the user could search on both fields independently. I think this is a bit clunkier for a user interface perspective though.
your last assumption sounds good. I have a search dialog and let the user enter both name and/or location. As soon as the user entered values in both (name and location) you can let him chose between an AND or OR search.
So the logic behind AND and OR search is something you have to implement. Keep care where it says exactly match.
i have also the B&S. I implemented 2 ComboBoxes with the distinct values of the database for each field + a keyword "any". If the user select both ComboBoxes with a value other than any, than i use AND. If the user select one ComboBox with a value other than any, than i only search for this value.
One reasonable interpretation of the requirement would be that they have to be able to sort by either NAME or by LOCATION, and you also have to support a search on both NAME and LOCATION. What people keep saying on these forums is that as long as you are interpreting the requirements in a meaningful way, it is OK. So my conclusion is, you can support OR searches if you want to, but you don't have to.