You are required to implement a simple online auction system using Java socket API. Two applications (client and server) using TCP connection are required. The client application (named ClientBid) allows users to logon to the server in order to join the auction and bid for items. The server application (named ServerAuction) hosts the auction, authenticates user logons, sends announcements to buyers advertising the item, accepts bid from clients and informs clients whether their bids are successful or not. There are different models of auction. The most well-known model is English auction, in which bidders announce higher bids publicly until there is no higher one. The item is then sold to the buyer with highest bid. In this assignment you are required to implement another auction model called a Yankee auction, in which a number of a commodity item is auctioned off and buyers have to specify the bids and the quantity to buy. When the auction completes, the highest bidder will be allocated the corresponding quantity in the bid. The next highest bidder will get a share from the remaining items. This continues until all items are allocated. This implies that the lowest successful bidder may not be able to get the desirable number of items. The unit price that ALL bidders pay is the price bid of the lowest successful bidder.
PART B
Assignment 1 : Socket Application
Overview
This programming assignment is to let you become familiar with socket programming and client
server interactions.
You are required to implement a simple online auction system using Java socket API. Two
applications (client and server) using TCP connection are required. The client application
(named ClientBid) allows users to logon to the server in order to join the auction and bid for
items. The server application (named ServerAuction) hosts the auction, authenticates user
logons, sends announcements to buyers advertising the item, accepts bid from clients and
informs clients whether their bids are successful or not.
There are different models of auction. The most well-known model is English auction, in which
bidders announce higher bids publicly until there is no higher one. The item is then sold to the
buyer with highest bid. In this assignment you are required to implement another auction model
called a Yankee auction, in which a number of a commodity item is auctioned off and buyers
have to specify the bids and the quantity to buy. When the auction completes, the highest bidder
will be allocated the corresponding quantity in the bid. The next highest bidder will get a share
from the remaining items. This continues until all items are allocated. This implies that the
lowest successful bidder may not be able to get the desirable number of items. The unit price
that ALL bidders pay is the price bid of the lowest successful bidder.
Take an example:
?A seller put 100 books for auction.
?Alice bids $50 for 40 books.
?Bobby bids $40 for 30 books.
?Charles bids $30 for 20 books
?Daisy bids $20 for 20 books
?Ellen bids $10 for 10 books
?30 other people bid $5 for 1 book
At the end of auction, Alice gets 40 books, Bobby gets 30 books, Charles gets 20 books and
Daisy gets 10 books. All of them pay $20 per book.
The actions to be performed by the client are listed below:
- Start client to connect server host at a specific port number:
o ClientBid hostname 5193
- Prompt user for username and password:
o username:xxxxx
o password:yyyyy
- Connect server and send username and password to server for authentication. Receive
response from server and the corresponding message on screen. It could be an error
message for invalid user, notification of the outcome of the user’s bid in previous
auctions, a description about the current auction, or any other messages that are
appropriate to your online auction system. For example:
o Welcome user xxxxx
o Congratulations, in the previous auction of commodity item (ID: 99999, cp3003
textbook) you have successfully bought 2 items ($10 per item).
o The current auction starts at Mar 1, 2006 16:00 and finishes at Mar 3, 2006
16:00.
o Item ID: 66666, cp3003 exam answer. Quantity available: 100. Minimum price
per item: $10
- Prompt user to bid::
o quantity to buy (0 to exit):4
o your bid price per item: 12
- Send bid to server and wait for response from server:
o Thank you, you will get notice after auction finish. Good luck! Bye.
- Close connection to server and exit.
The actions to be performed by the server are listed below:
- Start server by specifying the port number to run the application, and the input text filethat specifies the auction details: item ID, item desciption, quantity available, minimumprice per item, and date/time for this auction to finish. For example,
o ServerAuction 5193 auctionItemFile.txt
- Two text files are required to run server. The first one is the input text file specifyingauction details as mentioned above. The second one is the text file storing userdatabase: username, password, bid outcomes etc. A third output text file may berequired for storing bid information, e.g. username, quantity request, bid price, etc. Whenthe auction is finished, this file could also store the list of successful bidders, the quantityallocated to each successful bidder and the price per item.
- When clients connect, validate username and password. Display appropriate messageto client and prompt user to bid as mentioned above.
- Wait for user to bid. If no response is received from user in 5 minutes, close the
connection. (see setSoTimeout())
- Check user input for valid price and quantity.
- Store the corresponding bid details.
- Notify user that the bid is received and close connection.
- When auction time finishes, close all existing connections from users. Allocate the itemsto bidders accordingly and determine the final price per item. The bid outcome for each
bidder should be written to the user database text file so that user knows the outcome
when they logon to the system later.
You have to design the record format of those text files. You may add other fields in the files
that you think are appropriate to your system. Also, you may include additional files, e.g. a third
text output file storing the current bid information and the auction results.
There are some situations that you have to take into considerations when writing the
client/server applications:
?How can a bidder know that the bid has been sent to the server successfully? There
should be a response from server after the bid is received. However, the message might
get lost, the connection could be broken, the server might be down, ………
?How to handle the situation where a user logs-on and bids more than once, e.g. bids for
an item for 10 units @ $6 in the first time, and bids for the same item for 15 units @ $5 in
the second time?
?The machine could be shutdown while running the auction server application. The server
has to be restarted. Does it affect the previous bids made before the machine went
down?
Marking Criteria
- [10 marks] Validate username/password.
- [5 marks] Display to client the welcome message and description of current auction.
- [5 marks] Validate user’s bid and response appropriately.
- [10 marks] Timeout if no input from client for 5 minutes.
- [10 marks] Close connection when auction time expires.
- [20 marks] Allocate the items to successful bidders and determine the price correctly.
- [10 marks] Notify user about the bid outcome.
- [10 marks] Usage of threads. Note that without threads, the auction system still works,
but it can only handle one connection at a time.
- [20 marks] Robustness of the system.
- [Bonus 10 marks] You get bonus marks if server is able to periodically inform allconnecting user about the time left for an auction.
What to Hand In
The deliverables are:
?Client source code
?Server source code
?Output
?Descriptions about how to run, e.g. sample runs
Make sure that your codings are runnable and produce correct results. You may be required to make arrangement with your lecturer to demonstrate your program. As usual, we expect well commented code with descriptive identifier names and neat presentation.Make sure that your codings are runnable and produce correct results. You may be required to make arrangement with your lecturer to demonstrate your program. As usual, we expect well commented code with descriptive identifier names and neat presentation.
Previous answers to this question
This is a preview of an assignment submitted on our website by a student. If you need help with this question or any assignment help, click on the order button below and get started. We guarantee authentic, quality, 100% plagiarism free work or your money back.
Get The Answer