Results 1 to 2 of 2
  1. #1
    lukote04 is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Angry this code is not working I Dont know why ? Public void close the last code!!

    Java Code:
    import java.util.ArrayList;
    
    /**
     * A simple model of an auction.
     * The auction maintains a list of lots of arbitrary length.
     *
     * @author David J. Barnes and Michael Kölling.
     * @version 2011.07.31
     */
    public class Auction
    {
        // The list of Lots in this auction.
        private ArrayList<Lot> lots;
        // The number that will be given to the next lot entered
        // into this auction.
        private int nextLotNumber;
        private int getHighestBid;
       
        
        /**
         * Create a new auction.
         */
        public Auction()
        {
            lots = new ArrayList<Lot>();
            nextLotNumber = 1;
        }
    
        /**
         * Enter a new lot into the auction.
         * @param description A description of the lot.
         */
        public void enterLot(String description)
        {
            lots.add(new Lot(nextLotNumber, description));
            nextLotNumber++;
        }
    
        /**
         * Show the full list of lots in this auction.
         */
        public void showLots()
        {
            for(Lot lot : lots) {
                System.out.println(lot.toString());
            }
        }
        
        /**
         * Make a bid for a lot.
         * A message is printed indicating whether the bid is
         * successful or not.
         * 
         * @param lotNumber The lot being bid for.
         * @param bidder The person bidding for the lot.
         * @param value  The value of the bid.
         */
        public void makeABid(int lotNumber, Person bidder, long value)
        {
            Lot selectedLot = getLot(lotNumber);
            if(selectedLot != null) {
                Bid t = new Bid(bidder, value);
                boolean successful = selectedLot.bidFor(t);
                if(successful) {
                    System.out.println("The bid for lot number " +
                                       lotNumber + " was successful.");
                }
                else {
                    // Report which bid is higher.
                    Bid highestBid = selectedLot.getHighestBid();
                    System.out.println("Lot number: " + lotNumber +
                                       " already has a bid of: " +
                                       highestBid.getValue());
                }
            }
        } 
    
        /**
         * Return the lot with the given number. Return null
         * if a lot with this number does not exist.
         * @param lotNumber The number of the lot to return.
         */
        public Lot getLot(int lotNumber)
        {
            if((lotNumber >= 1) && (lotNumber < nextLotNumber)) {
                // The number seems to be reasonable.
                Lot selectedLot = lots.get(lotNumber - 1);
                // Include a confidence check to be sure we have the
                // right lot.
                if(selectedLot.getNumber() != lotNumber) {
                    System.out.println("Internal error: Lot number " +
                                       selectedLot.getNumber() +
                                       " was returned instead of " +
                                       lotNumber);
                    // Don't return an invalid lot.
                    selectedLot = null;
                }
                return selectedLot;
            }
            else {
                System.out.println("Lot number: " + lotNumber +
                                   " does not exist.");
                return null;
            }
      public void close()
       {
       for(Lot l:lots)
       {System.out.print("lot" + l.getNumber() + ":" + l.getDescription() + ":" );
        Bid b = b.getHighestBid(); 
       if ( b == null)
       {System.out.println("no bid");}
        else{System.out.println("HighestBidder:" + b.getBidder().getName() + ":Bid:" + b.getValue());}
       }
       }
       
    }
    Last edited by Fubarable; 03-25-2012 at 02:41 AM. Reason: code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: this code is not working I Dont know why ? Public void close the last code!!

    Consider telling us more about your problem such as any and all error messages including the complete message text, and full description of behavior problems. Please remember that we are all volunteers, and so the onus of putting in the major effort for solving this should be yours. In other words, try putting in more effort so as to make it easier for us to be able to help you.

    Moving to the New to Java forum.
    Code tags added.

Similar Threads

  1. Replies: 3
    Last Post: 03-01-2012, 03:17 PM
  2. Replies: 1
    Last Post: 11-21-2011, 07:46 PM
  3. Replies: 1
    Last Post: 12-04-2010, 05:41 PM
  4. Replies: 3
    Last Post: 07-30-2010, 10:27 AM
  5. How do I close Cancel Dialog Box by code
    By thedatawarehouse in forum SWT / JFace
    Replies: 2
    Last Post: 12-22-2009, 06:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •