Data.java must implement DBMain interface which contains the method : public int find (String criteria) throws RecordNotFoundException
a non null vcalue in criteria[n] matches any field value that begins with criteria[n]
On the other hand,it was mentionned that : the user interface must allow the user to search the data for all records, or for records where the name/or location fields exactly match value specified by the user.
-I need to implement find so that it returns String values not int and the returned data must match exactly the criteria specified by the user not begining with it
1) About returning String, you can just get the int and then call the read(int) method for each of the ID's. Although it certainly is not an optimized solution, is the one that uses only the given interface.
You can also assume that the interface is required but not necessarily needs to be used by you. In this case, the given interface will probably be used by an automated test engine. You may then create another interface that is used by your business layer that contains a String findValues(String) method (or subclass the existing interface). I am not sure this is a valid way out, though. Since I had no such problems with my interface, I am just sticking with the given interface (and doing like the first solution I mentioned).
2) Now, the exact match is problematic. You could use the starts-with (SW) method and then re-test the matches in the business layer.
You could also take advantage of the fact data on the data file has blank spaces filling the space (at least in my case) and send a query also with blank spaces.
If you are using a different interface as the second solution for the first problem, you may just specify that the String findValues(String) method just do exact matches.
Well, you get the point... it looks like some weird solution is necessary.
I totally rejected the idea of padding search criteria with spaces in order to match the database values. Instead I offer two combo boxes name and location filled with all respective values from the database (duplicates excluded, of course), so that the user does not have to enter spaces manually. In addition the combo boxes are made editable, so that if the user wants to enter a value, he can do this. Of course, the last possibility does not make sense for this assignment but the requirement is fulfilled, anyway.
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop