The idea is different lots in an auction. I know I need a return statement of type "Lot" however I am not sure what that would be. Here is my code.
public Lot getLot(int lotNumber)
{
int index = 0;
boolean found = false;
while(index < lots.size() && !found) {
Lot selectedLot = lots.get(index);
if(selectedLot.getNumber() == lotNumber) {
found = true;
}
else {
index++;
}
}
if(!found) {
found = false;
}
}
What you could do is something similar to this, what this will do is if a match is found it will return the selectedLot which was the match, and if no match was found it would return null:
public Lot getLot(int lotNumber) {
int index = 0;
while(index < lots.size()) {
Lot selectedLot = lots.get(index);
if (selectedLot.getNumber() == lotNumber) {
return selectedLot;
} else {
index++;
}
}
return null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With