[Bluej-discuss] exercise 4.24 Objects with Java Blue-J
RDP
robdepasquale at msn.com
Sat Apr 8 15:41:02 BST 2006
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
|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060408/db6aee7f/attachment.html
More information about the bluej-discuss
mailing list