[Bluej-discuss] exercise 4.24 Objects with Java Blue-J
Luis Moreira
Luis.Moreira at jet.uk
Tue Apr 11 06:09:22 BST 2006
Hi Marco,
This is the way I see it:
You get the lot's highest bid which is of type Bid, Bid has a bidder
which is of type Person, this Person as a name.
Lot.getHighestbid() . getBidder() . getName()
Returns Bid returns Person returns Persons name
Hope it helps
Regards
Luis
-----Original Message-----
From: bluej-discuss-bounces at bluej.org
[mailto:bluej-discuss-bounces at bluej.org] On Behalf Of Marko Bajic
Sent: 09 April 2006 07:06
To: robdepasquale at msn.com
Cc: bluej-discuss at bluej.org
Subject: Re: [Bluej-discuss] exercise 4.24 Objects with Java Blue-J
Thankyou very much. The method works perfectly.
I am a little confused with the syntax of the method call:
lot.getHighestBid(). getBidder().getName().
Could you please explain or tell me where this is in the book.
Thanks again,
Marko
>From: "RDP" <robdepasquale at msn.com>
>Reply-To: "RDP" <robdepasquale at msn.com>
>To: "General discussion for users of BlueJ" <bluej-discuss at bluej.org>
>CC: <mbnov26 at hotmail.com>
>Subject: Re: [Bluej-discuss] exercise 4.24 Objects with Java Blue-J
>Date: Sat, 8 Apr 2006 10:41:02 -0400
>
>Marko,
>
>Try something like this:
>
>
>public void closeLots()
>{
>Iterator it = lots.iterator();
>while(it.hasNext()) {Lot lot = (Lot) it.next();
>if(lot.getHighestBid() != null){
>System.out.println(lot.toString()+ " ITEM SOLD TO: " +
>lot.getHighestBid().getBidder().getName());}
>else
>System.out.println(lot.toString() + " ITEM NOT SOLD!");}
>}
>
>
>This is what get's the name:
>
>lot.getHighestBid().getBidder().getName()
>
>-Rob
>
>
>----- Original Message -----
>From: "Marko Bajic" <mbnov26 at hotmail.com>
>To: <bluej-discuss at bluej.org>
>Sent: Saturday, April 08, 2006 4:23 AM
>Subject: [Bluej-discuss] exercise 4.24 Objects with Java Blue-J
>
>
>|I am having trouble with exercies 4.24 of objects Java Blue-j. I have
done
>| everything but the program does not want to show the name of the
bidder.
>I
>| compile the program and it shows no syntax error but when I get to
>| initializing the close method the NoSuchElementException error
message
>| appears. Here is my program:
>|
>| public void close()
>| {
>| Iterator it = lots.iterator();
>| while(it.hasNext()) {
>| Lot lot = (Lot) it.next();
>| Bid bid = (Bid) it.next();
>| if(lot.getHighestBid() == null){
>| System.out.println(lot.toString() + "unsold");
>| }else{System.out.println(lot.toString()+ " sold" +
bid.getBidder());
>| }
>| }
>|
>| It prints out the name of the lot and the price it was sold for and
if it
>| was sold or not but it does not show the name of the bidder. Please
help
>me
>| so I can continue my work with the book.
>|
>| Thankyou
>| Regards,
>| Marko Bajic
>|
>| _________________________________________________________________
>| New year, new job - there's more than 100,00 jobs at SEEK
>|
>http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2E
au&_t=752315885&_r=Jan05_tagline&_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
>|
_________________________________________________________________
Test drive new cars from the comfort of your desk at carpoint.com.au
http://secure-au.imrworldwide.com/cgi-bin/a/ci_450304/et_2/cg_801459/pi_
1004813/ai_833884
_______________________________________________
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