Goal. In this project you will simulate an auction service in which sellers can offer items and
bidders can bid on them. In particular, you will implement a class, AuctionServer, in Java
that provides methods supporting all aspects of an auction. Because many sellers and bidders
will be interacting at the same time, the program must be thread-safe.
Getting started. The project skeleton can be downloaded as a zip file from the course website.
The directions given in Project 0 may be used to unpack the zip file to create a project named
“p1” in Eclipse (similar approaches apply for other IDEs as well).
Restrictions. The focus of this project is to learn how to write thread-safe code. For this
reason, you are not allowed to use any concurrent collections in the Java libraries. Specifically,
do not use anything contained in java.util.concurrent or the synchronized collections
in the Collections class in java.lang.Object. You may use the regular (i.e. nonsynchronized)
version of collections if you wish, however.
Specification in Detail. The auction service follows a basic client/server model. There are two
types of clients: Sellers and Bidder. A Seller will never be a Bidder, and vice-versa.
a. can submit new Items to the server
a. Can request a listing of current Items
b. Can check the price of an Item
c. Can place a bid on an Item
d. Can check the outcome of a bid
e. Can pay for Items they have won
These actions will be implemented as methods in the AuctionServer.
There are a number of restrictions which must be enforced with regards to listing and bidding.
a. Sellers will be limited to having maxSellerItems different active Items at any given time.
b. The AuctionServer will have a limit, serverCapacity, for the number oftotal active Items offered from all Sellers.
a. New bids must at least match (greater than or equal to, >=) the opening bid if no one else has bid yet, or exceed (strictly greater than, >) the current highest bid if other bids have already been placed on the item.
b. Bidders will be limited to having maxBidCount active bids on different current items.
c. Once a Bidder holds the current highest bid for an item they will only be allowed to successfully place another bid for that item if another Bidder overtakes them for the current highest bid.
d. Once a Bidder has won an auction, they must pay at least the amount of their bid in order to receive the item.
One situation that can occur during an auction is that a Bidder could place several bids which sum to an amount that is higher than the Bidder can afford, thinking that they are bound to not win all of the items which they have bid upon. If the Bidder is in fact the high bidder for all these items, then they would not be able to pay for all these items, thereby shortchanging the auction and other Bidders who might have won items otherwise. To discourage this behavior, if a Bidder is unable to pay the AuctionServer at least the amount of their bid for an item which they have won, that Bidder will have all their active bids1 cancelled and will be permanently banned from placing bids on the AuctionServer in the future. When a bid is cancelled in this manner, it is as if the item was never bid upon (i.e. someone may restart bidding on the item at the opening price, provided the bidding is still open, although the remaining duration for the item is not reset).
You may make the following assumptions when implementing the AuctionServer:
a. All prices will be listed in whole dollars only.
b. All items will open with prices greater-than or equal-to zero.
c. All items will open with bidding durations greater-than zero.
d. If an auction expires with no bids placed, or if the winning bidder is unable to pay for the item, the Seller will not re-list the item, and the server receives no profit from it.
a. Items can receive any number of bids as long as the auction has not expired.
b. Once a bid has been placed it cannot be retracted by the Bidder.
c. A single Bidder cannot place more than one bid at a single moment.
The Seller class and two different Bidder client classes have been implemented for you. You will note that they all implement the Client interface that is provided. We have also given an Item class. Many clients will run in different threads, and will all access the singleton instance AuctionServer that you will be implementing.