[Bluej-discuss] Excercise 4.25 review please

RDP robdepasquale at msn.com
Sun Jun 18 23:24:20 BST 2006


JD,

You've just discovered the "eternal method call" using DOT NOTATION (contrast "internal method call").

See Page 67 in the text book which explains calling methods of other objects.

details += " sold for $" + highestBid.getValue() + "  to: "  +  highestBid.getBidder ().getName();

Your code above is what did it.

Unfortunately, I think the text does not explain nor present more examples of external method calls using dot notation.

Hey good luck!!

Best regards,

Rob DePasquale
Bon Vivant!
  ----- Original Message ----- 
  From: JD 
  To: bluej-discuss at bluej.org 
  Sent: Sunday, June 18, 2006 1:36 PM
  Subject: [Bluej-discuss] Excercise 4.25 review please


  Hi all!

  Please review and comment on my solution for Exercise 4.24.  I have a question at the bottom of this email as well.

  Auction Class:

       /**
       * Close Lot 
       * @return Close lots
       */
      
      public void closeAuction()
      {
          Iterator it = lots.iterator();
          while(it.hasNext()) {
              Lot lot = (Lot) it.next();
              System.out.println(lot.closeLot());
          }
      }


  Lot Class:

      /**
       * @return A string representation of this lot's details.
       */
      public String closeLot() 
      {
          String details = number + ": " + description;
          if(highestBid != null) {
              details += " sold for $" + highestBid.getValue() + "  to: "  +  highestBid.getBidder ().getName();
          }
          else {
              details += "    (No bid)";
          }
          return details;
      }
      

  Output:

  1: Car sold for $3432  to: Carl 

  2: Cat    (No bid)


  Question:

  The following line of code gave me the most grief until I got it working.

  highestBid.getBidder().getName(); 

  It is an object reference to a method to another object to a method within the object referenced by the getBidder() method!?!?!?  It works.  But what the heck did I create here?  What is it called?  Have we covered this type of construction in the book yet and I missed it? 




------------------------------------------------------------------------------


  _______________________________________________
  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/20060618/27c9a471/attachment.html


More information about the bluej-discuss mailing list