To run the project using the JAR files, clone the repository and run the following commands once to start the server:
cd .../Antique_Haven-Online_Auction/Server/bin
java -jar Server.jar
Then, run the following commands as many times as you wish in CMD only (since Client is a console application):
cd .../Antique_Haven-Online_Auction/Client/bin
java -jar Client.jar
Note: The JAR files cannot be ran outside of their respective directories since local dependencies exist.
Alternatively, simply compile and run the source code, labeled Server.java and Client.java.
- When starting up the client, you will first see a login page. Choose to either enter as an authorized user (via username and password), or as a guest.
Note: Available logins that the server will accept are kept in the file labeled logins.txt, which is in the Server directory.
- The GUI will indicate whether an incorrect login was entered. If a valid login is entered (or if you decide to enter as guest), you will be directed to a new scene showcasing pictures of all the available items, parsed through the itemInputs.txt file, as well as all auction activity, including notications of those who enter and leave the auction, every past and current bid on every item, and the final bid/purchase of sold items.
- Click on any picture to be directed to yet another scene detailing that very item. In every item-specific scene, you will be exposed to the item’s name, description, a clearer picture, the item’s starting/current bid, and options to enter a custom bid or instantly purchase an item.
-
- If the user enters a starting bid, their bid will be globally visible in the bottom left of that item screen, and a timer will pop up on the top left of the item screen. This timer is a global timer hosted on the server- all other customers in the auction will also see it on their screen. When it expires, the auction for that specific item will shut down and be sold to whoever made the latest bid.
-
- Alternatively, any customer can also “purchase” an item for a stated price at any time. If a customer decides to do so, the auction for that item will immediately shut down and be sold.
-
- All bids from start to sell will be displayed on the top right of the item-specific screen. When an item is finalized, the winning bidder and bid will be showcased in bold for that item, shutting down further bidding.
- Click the logout button in the bottom right of the homepage to exit the auction and be redirected into the login screen.
- When the auction is over (in the sense that all items have been sold), the owner and winning bid of each item will be detailed server-side in the file labeled AuctionLogs.txt.
- Frontend: JavaFX, CSS
- Backend: Java
Upon server startup, the program will first initialize an ArrayList of Items through an input file labeled inputItems.txt and a HashMap of accepted logins via logins.txt. It will then proceed to create a ServerSocket and wait until a client connection is established.
In the client file, a login GUI is first provided before a server-client connection is attempted. It is only after the client tries to login to the auction will a connection be established. After the server detects a client connection, it will then create a new thread that creates Printwriters and BufferedReaders to handle IO between server/client. Also, since the server class extends Observable, the client will also be added as an observer to the server. On the client side, a new thread will be created that now constantly listens for server input, since the client is now an observer.
Now, the client will be directed to the auction home page GUI. If the client chooses to bid on an item, the server will get a notification of this bid, update its own item class, store the bid, the owner, start the timer, and redirect to all current customers of this bid, by which their GUI’s are appropriately modified. The server also contains an ArrayList of each specific item’s bid history as well as an ArrayList that stores all auction activity, which is updated accordingly upon each bid, purchase, login, etc. When a new client logs in the middle of the auction, (after some bids have been placed and some items have already been sold), the server will indicate this to the client when setting up the new client’s auction scenes. This way, timers will be synced across all clients, and all current bids will be up to date across the board. It is also important to note that the server’s processRequest method is synchronized, so once one input is given from a particular client, other inputs will be put on hold until this is processed in order to avoid obvious conflicts.
Upon a client logout, the socket connection and the IO streams are all closed accordingly as the client re-enters the login screen and is no longer an observable of the server.