An auction item requires the following details to be maintained in the system: item ID, item description, 
seller ID, starting price and the auction status (open or closed). Once the auction has been opened the system will also need to maintain the details of the highest bidder 
and the amount they have bid on the item. You should start by designing and implementing a basic AuctionItem class, as follows:     1.  Define instance variables for the item ID (an    int), item description (a String), seller ID (a 
        String), starting price (a double), auction status (a Stringwhich can be “Pending”, 
        “Open”or “Closed”) the current highest bid (a double) and the ID of the current highest 
        bidder (a String).     2.  Define a constructor for the AuctionItem class which accepts the item ID, item description, 
        seller ID and starting price as parameters and stores the information in the corresponding 
        instance variables.         This constructor should also set the auction status to “Pending” and the highest bid to zero (0).           NOTE: You should not have parameters for auction status, highest bid (which are both initialised 
                  as discussed in the point above) or the bidder ID (which will be updated when a valid bid is 
                 placed on the item).     3.  Define appropriate accessors for the each of the instance variables in this class.     4.  Define a method public boolean hasBids(), which returns true if a valid bid has been 
        placed on the item and false if no bid has been made (hint: a valid bid has been made if the 
        current highest bid is equal to or greater than the starting price).     5.  Define a method public double open(), which functions as described below:         If the current auction status is “Closed” “Pending” then it changes the status to “Open”,  
        calculates the listing fee for the item based on the starting price and returns the result.             The price structure for listing fees is as follows:                                  Starting Price                         Listing Fee                                  $0.01 - $5.00                         $0.25 $0.20                                  $5.01 - $20.00                            $0.50                                $20.01 - $ 100.00                           $1.00                                $100.01 - $250.00                           $2.50                                    > $250.00                               $5.00              All listing fee amounts are rounded up to the nearest cent.              There is no need to round up listing fee amounts. 
6.  Define a method public double close(),which functions as described below:     If the current auction status is “Open” then it changes the status to “Closed”, calculates the sale fee 
    for the item based on the sale price (highest bid) and returns the result.     The price structure for sale fees is as follows:                          Sale Price                             Listing Fee                     Not sold or < $1.00                       $0.00 (no fee)                       $1.00 - $100.00                        5% of sale price                     $100.01 - $ 1000.00              $5 + 3% of (sale price – 100)                          > $1000.00                 $32 + 1% of (sale price – 1000)                  Note: All sale fee amounts should be rounded up to the nearest cent 
                                          (this is still a requirement)     If the auction status is not “Open” then this method should return a result of -1.     For points 6 and 7 5 and 6 you might find it useful to define separate methods for calculating the 
    listing and sale fees (which you can then call when needed in the open and close methods), as it will 
    make the changes that will be required for calculating listing and sale fees easier to implement in 
    assignment four. 7.  Define a method public int placeBid(double bidAmount, String bidder)which 
    attempts to place a bid on the item being auctioned.     If the auction status is “Open”, the bid amount is greater than or equal to the starting price and is also 
    greater than the current highest bid then the bid should be accepted, resulting in the highest bid 
    being set to the new bid amount and the highest bidder being set to the bidder ID that was passed in 
    as a parameter.     After the highest bid and bidder information has been updated the method should return the value 
    zero (0) to indicate that the requested bid was successful.     If the auction status is not “Open” then the method should return a value of -1to indicate that the 
    auction is not yet open.     If the auction status is “Open”, but the bid amount does not meet the requirement of being greater 
    than or equal to the starting price and also being greater than the current highest bid then the method 
    should return a value of -2to indicate that the bid was not successful. 8.  Define a method public void print(), which prints a summary of the details (instance 
    variables)  for the current ActionItem to the screen.           NOTE: The details of the AuctionItem object should be printed in a neat format as shown in the 
                  screenshots provided later in this document. 题目在此 会的帮帮忙 
留下联系方式 酬谢

解决方案 »

  1.   


    好像是让写一个类AuctionItem 要求 1 定义了这个类的属性 及属性的类型
    要求 2 定义了构造函数的参数
    要求 3 添加set get方法
    要求 4 写一个public boolean hasBids()方法
    5~8 也是写 open close print 等方法如果翻译过来的话 感觉很无聊。
    估计是面试题。。
      

  2.   

    1.定义int类型的itemID变量,String类型的itemdescription,String类型的sellerID,double类型的startingprice,String类型(可以参考“Pending”, 
      “Open”or “Closed”来表示3种状态)的auctionstatus,double类型的bid(表示最高出价),String类型的bidder(表示最高出价的出价者),它们的实例。
    2.定义用来接收itemID,item description, seller ID 和 starting price这些参数的AuctionItem类构造函数。3.定义合适的函数来访问这里的每一个实例化成员变量。4.定义一个方法public boolean hasBids()来确定该item是不是已经被出价5.定义一个方法public double open(),方法说明:如果现在竞价器显示的是Closed” 或者“Pending”状态,通过这个函数你要把它变成”Open”状态并且计算列表中item的最终价格,返回结果。6.定义方法public double close(),方法说明:如果现在的状态是“Open”,就把它变成“Closed”并且计算列表中item的最高竞价,返回结果。7.定义方法public int placeBid(double bidAmount, String bidder),方法说明:如果现在的状态是“Open”,并且竞价>=起价或者当前的最高竞价就修改当前最高竞价,然后竞价者的ID修改为现在出价最高的竞价者的ID,最后返回0来表示update成功。如果现在的竞价状态不是“Open”或者竞价<=起价或者当前的最高竞价就返回-2来表示竞价不合法。8.定义方法public void print(),方法说明:用来显示现在正在拍卖的item的详细信息,输出到屏幕上(要求:格式要整洁,要做好日志备份)。