Results 1 to 4 of 4
- 01-10-2011, 01:37 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 1
- Rep Power
- 0
Search function with multiple hits and ability to chose what hit is correct?
Hi. My first post here. :)
I've made a program handling customers, orders, and products of a small buisness, using arraylists, as a schoolproject. My search function:
public Order searchOrder(int orderNo){
Order tmpOrder = null;
int i = 0;
boolean found = false;
while (i < orderrow.size() && funnen == false){
tmpOrder = orderrow.get(i);
if (tmpOrder.getOrderNo() == orderNo) {
found = true; }
i++;
}
if (found == false) {
tmpOrder = null;
}
return tmpOrder;
}
My problem is that an order can have several different "orderrows" containing different products but still be a part of the same order (same id). Is there a way I can search for all of them and display them (if more than one) in a pop-up window where I could chose which one I was looking for and import that one for possible edit.
Thanks in advance. :)
- 01-10-2011, 01:41 AM #2
Member
- Join Date
- May 2010
- Posts
- 12
- Rep Power
- 0
hmmh put all the orders with the same id in an array. Then search that array for the name of the item you wish to edit.
not sure if this will work but you can give it a crack.
- 01-10-2011, 01:50 AM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
If I understand what you are asking....a) you could use and return another List containing the found elements or b) use a Map, keyed with ordernum and valued with the List containing the contents
-
Yes. How you do this will depend on the structure of the Order class, something you've not told us a lot about. But also, is this a GUI program or a command line program? Regardless, you'll want to create a non-GUI selectOrderItem method and perhaps an enumerateOrderItems method which returns a List of items and then use these methods in your GUI or non-GUI program depending on the need.
Also, please read the first link in my signature links below on how to use code tags. Your post without tags is very hard to read.
Much luck!
Similar Threads
-
Pass multiple object types to one function
By desmo in forum New To JavaReplies: 3Last Post: 10-08-2010, 07:51 AM -
Simple search-function: what am I doing wrong?
By Bas in forum New To JavaReplies: 4Last Post: 07-23-2009, 09:45 PM -
Search function for ArrayList?
By javanoobie in forum New To JavaReplies: 11Last Post: 04-17-2009, 08:38 PM -
Code for adding search function in an application
By Avdhut in forum Threads and SynchronizationReplies: 5Last Post: 03-03-2009, 10:15 AM -
make search function ike eclipse search in window->preference
By i4ba1 in forum Advanced JavaReplies: 5Last Post: 08-26-2008, 03:43 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks