[Bluej-discuss] Excercise 4.24
Michael Kölling
M.Kolling at kent.ac.uk
Sun Apr 2 15:08:14 BST 2006
On 2 Apr 2006, at 9:23, Marko Bajic wrote:
> I was wondering if I could have some help on a particular question.
> Exercise 4.24 of Objects with Java Blue-J is giving me
> problems. Here is
> my
> code so far. I might be miles off for all I know.
> public Lot close()
> {
> Iterator it = lots.iterator();
> while(it.hasNext()) {
> Lot lot = (Lot) it.next();
> if ( [I'M NOT SURE WHAT GOES HERE] >1){
> System.out.println(lot.toString()+ "sold");
> }else{
> System.out.println(lot.toString() + "unsold");
> }
> }
> }
That's a good start.
The missing if-statement should say something like
if (THERE-WAS-AT-LEAST-ONE-BID) {
...
}
To test whether there was a bid, you can use the Lot's getHighestBid
() method. (Have a look at the comment for that method: it says that
it will return a Bid, or null if there was no bid.)
So you might write something like
if(ATTEMPT TO GET LOT'S HIGHEST BID IS NOT NULL) {
...
}
Regards,
Michael
More information about the bluej-discuss
mailing list