Hi all,
I have a customer's name as an attribute of a reservation object stored in my vector of reservation objects. My current search only does an exact match of a customer name. How do I do a partial word search eg. if my customer name is danielle and I only key in dan, how do i get it to return danielle?
Hope to hear from someone soon! Thank you!
Code:public void searchcustName(String custName, Vector v) { for( int i = 0; i < v.size(); i++) { Reservation aReservation = ((Reservation) v.elementAt(i)); if ((aReservation.getcustName().equals(custName))) {System.out.println("Record "+ i + " "+ aReservation.getcustName()+" "+aReservation.getCovers() +" "+ aReservation.getSmoking()+" "+ aReservation.getDate()+" "+aReservation.getstartTime()+" "+aReservation.getendTime()+" "+aReservation.getComments()); searchCount++; } } if (searchCount==0) System.out.println("The record of "+custName+" cannot be found!"); else System.out.println("Number of records found: "+searchCount); }


Reply With Quote


Bookmarks