Hi.
I´m having some trouble with my search code.
I'm trying to make it search in either my varenummer field or varenavn field.
My method to do so looks like this:
public KasseInterface søgVare( String varenummer, String varenavn ) {
System.out.println( "Søger efter vare med varenummer: " + varenummer);
for( KasseInterface elem : varer ) {
if (elem.getVarenummer().equals(varenummer) ) {
return elem;
}
else if (elem.getVarenavn().equals(varenavn) ) {
System.out.println("fandt vare '" + elem + "'");
return elem;
}
}
System.out.println("fandt ikke nogen vare!!!");
return null;
}
Somehow it'll only search for my varenavn, not my varenummer, can someone see why?
Also.. I would like to make it so you can either enter varenummer or varenavn, but I haven't figured how to do this. I have tried to do this :
public KasseInterface søgVare( String varenummer || String varenavn ) {
without any luck.
Can anyone help?
Thanks.
Regards
Christian