[Bluej-discuss] Excercise 4.24

Todd O'Bryan toddobryan at mac.com
Tue Apr 4 13:50:23 BST 2006


It's not listed in the book, but I believe the Lot class has a  
getHighestBid() method, or something similar.

You may want to use that.

Todd

On Apr 4, 2006, at 6:22 AM, Marko Bajic wrote:

>
>
> Thankyou, but i am still having troubles. I write:
>
> public Lot close()
>    {
>        Iterator it = lots.iterator();
>        while(it.hasNext()) {
>            Lot lot = (Lot) it.next();
>            if(highestBid = null){
>          System.out.println(lot.toString() + "unsold");
>        }else{System.out.println(lot.toString()+ "sold");
>
>        }
>    }
>
> I just get a message that it is uunable to find highestBid. I know  
> I have to make it visible from here but I do not know how.
>
> Thankyou,
> Marko
>
>
>> From: Michael Kölling <M.Kolling at kent.ac.uk>
>> Reply-To: General discussion for users of BlueJ <bluej- 
>> discuss at bluej.org>
>> To: General discussion for users of BlueJ <bluej-discuss at bluej.org>
>> Subject: Re: [Bluej-discuss] Excercise 4.24
>> Date: Sun, 2 Apr 2006 15:08:14 +0100
>>
>> 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
>>
>> _______________________________________________
>> mailing list bluej-discuss at bluej.org
>> To unsubscribe or change your preferences, go to
>> http://lists.bluej.org/mailman/listinfo/bluej-discuss
>
> _________________________________________________________________
> Search for local singles online @ Lavalife - Click here  http:// 
> a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom% 
> 2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99% 
> 26locale%3Den%5FAU%26a%3D21550&_t=21550&_r=endtext&_m=EXT
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss



More information about the bluej-discuss mailing list