Forums Register Login
find method in the interface
Hi All,

I am working on urlybird, the find method defined from the interface as this:
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public int [] find(String [] criteria)

for the find method, i read some of the posts here. They are really useful, cleared most of my doubts.
I still thinking if i need to provide search function for all the room attributes, like date, max_occupancy, price and smoking.

if I add these attribute in the search function, does it mean that i need to use the startWith() for the criteria matching as indicate in the interface.
If I use equal() to match those parameters like price , date. will i violate the requirement ?

Heilien ,

In my instructions documents it specifies the following:

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.

It is you choise if you will choose to supply search criteria for all the fields, but the instructions sais that you sould provide for and name/location combinations.

Hi Heilien,

In my opinion there is a difference between the implementation in your Data class of the find-method and the search criteria you provide in your GUI. My find-method in the Data class is able to search on every possible room attribute (and I tested its functioning with a JUnit test, just like all other methods of my Data class). But in my GUI I provide just the 2 required search criteria: name and location, so in my GUI I just have 2 input fields, 1 for each criterium.

Adding more search criteria now to your gui has no added value, because it is not required.

Kind regards,
Hi Nicolas , Roel

thanks for the advice. I am planning to implement the find method for all attributes in the data class.
while in the GUI , only search for the location and hotel name for exact match.

in the data class, the interface specified that using
"Fred" matches "Fred" or "Freddy" as the example

In the data class, I think it is appropriate of using startWith() for hotelName and city
but for the maxOccupancy, smoking, price, date and customer using equal() exact match.
I am not sure if I should do this. The interface seems that it only restrict the find method to use startWith() for the search criteria

Hi Heilien,

I made in find-method no difference between location, name and the other ones, so all attributes were tested with startsWith. Because in the comments of the find-method there is also no difference:

A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)

Kind regards,
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 1126 times.

All times above are in ranch (not your local) time.
The current ranch time is
May 21, 2018 22:34:31.