[Bluej-discuss] exercise 4.24 Objects with Java Blue-J
Marko Bajic
mbnov26 at hotmail.com
Sun Apr 9 07:05:40 BST 2006
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%2Eau&_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
More information about the bluej-discuss
mailing list