- README for Purdue University CS 18000 Project 5, Option 3: Marketplace
- Created by:
- Junan Chen (chen4842)
- Sally Hou (hou151)
- Ian Kelimans (ikleiman)
- Daniel Mayer (mayer68)
- Lance Ying (ying43).
- Group 11, Lab 3
Icons are from Icons8: Link to Icons8
(This attribution is also shown in the "About" menu of the program.)
Compile the MenuGUI.java and Server.java files in src using JDK 9 or greater on a graphical system. Run the Server class first, then run the MenuGUI class and follow the on-screen prompts to use the program.
- Using
javac,java, andgiton Linux, macOS, or Windows:
$ git clone https://github.com/daniel-s-mayer/CS-180-Group-11-Project-5.git
$ cd CS-180-Group-11-Project-5
$ cd src
$ javac MenuGUI.java
$ javac Server.java
$ java Server
$ java MenuGUI
- Using a commercial IDE on all systems:
- Clone the git repository at https://github.com/daniel-s-mayer/CS-180-Group-11-Project-5.git
- Compile and run the
Server.javafile. - Compile and run the
MenuGUI.javafile. - Follow the on-screen prompts to use the program.
All test cases must be run in order from an originally "blank" system unless otherwise specified. To "clear" the system, delete the buyers.bin and sellers.bin files in the main project directory.
Error cases must also be run from a "blank" system.
- Daniel Mayer (mayer68) - submitted code on Vocareum workspace
- Ian Kleimans (ikleiman) - Brightspace submission of Project 5 Report.
- Junan Chen (chen4842) - submitted a fifteen minute, pre-recorded video presenting our work via Brightspace.
- Daniel Mayer (mayer68) - emailed a YouTube link to the presentation video in case of problems with Brightspace.
- Store.java
- Item.java
- Buyer.java
- Seller.java
- Purchase.java
- MenuGUI.java
- DashboardGUI.java
- LoginGUI.java
- MarketGUI.java
- BuyerMenuGUI.java
- BuyerShoppingCartGUI.java
- SellerImportExportGUI.java
- SellerMarketGUI.java
- SellerMenuGUI.java
- SellerSalesGUI.java
- SellerShoppingCartGUI.java
- StatisticsGUI.java
- Server.java
- ServerComm.java
-
Description: The
Buyerclass stores buyer objects, each containing the following fields: email address (String), password (String), past purchases (ArrayList), and shopping cart contents (ArrayList ). Setters and getters are provided for all of these fields, in addition to methods to print to the screen, export all past purchases made by the buyer, or create a list of unique stores from which the buyer has made a purchase. Objects of this class are created theBuyerPathwayclass and accessed as necessary from both theBuyerPathwayandSellerPathwayclasses. Likewise, this class implements theSerializableinterface to facilitate export to program data files. -
Testing: This class was tested via general program testing with simulated user input, as objects of this class are created, accessed, and modified throughout normal program operation.
-
Description: The
Sellerclass is largely similar to theBuyerclass, except that this class contains seller objects and contains fields for past sales (ArrayList) and stores (ArrayList) instead of a shopping cart or past purchases. Setters and getters are provided for each field, and objects of this class are created by theSellerPathwayclass and accessed by both theBuyerPathwayandSellerPathwayclasses. Like theBuyerclass, this class implements theSerializableinterface to facilitate file storage. -
Testing: Like the
Buyerclass, this class was tested with general program testing.
-
Description: This class is used to create objects for each
Purchasemade by a user. These objects are stored within ArrayLists inBuyer,Seller, andStoreobjects, allowing for organized storage of key purchase information. The class contains all necessary fields to represent a purchase, including price per unit (double), quantity purchased (int), item name (String), description (String), seller (Seller), buyer (Buyer), store (Store), and revenue (double). Setters and getters are included for each field in the class, and objects of this class are created in theBuyerPathwayclass and accessed by both theBuyerPathwayandSellerPathwayclasses. Like all other object classes, this class implements theSerializableinterface to facilitate file storage. -
Testing: This class was tested by recording values on paper, making sample purchases with the recorded values, and accessing the objects for those purchases from various parts of the program.
-
Description: This class is used for
Itemobjects throughout the program. TheseItemobjects are stored in ArrayLists throughout most classes of the program (notably theStoreclass), with eachItemobject containing the follow fields: name (String), price (double), quantity for sale price (int), sale price (double), quantity available (int), quantity purchased so far (int), per-order quantity limit (int), review (ArrayList), seller (Seller), description (String), store (Store). Setters and getters for each of these items are included, as is aproductPageTest()method to get formatted text for the product information page. Like the other object classes, this class implements theSerializableinterface to permit items to be saved to files. -
Testing: This class was tested by creating, editing, viewing, deleting, and purchasing items throughout the program.
-
Description: This class is used to create and access
Storeobjects throughout the buyer and seller pathways. EachStoreobject contains all necessary fields to fully represent a unique store (i.e. name, items, seller associated with the store, and sales), all of which have setters and getters.Storeobjects are created within theSellerPathwayclass and stored in eachSellerobject, and theseStoreobjects are accesed by both theBuyerPathwayandSellerPathwayclasses. Like all other object classes, this class implements theSerializableinterface to allow other classes to save these objects to files. -
Testing: This class was tested by creating, editing, viewing, and deleting stores and their member items and sales throughout general program execution.
- Description: This class serves as the GUI entry point into the program. It launches the main
JFramethat is used
throughout the program, and displays buttons for the user to select whether they are a buyer or a seller. Once a button
is selected, the class calls theLoginGUIclass to begin the correct (i.e. buyer or seller) "pathway." - Testing: This class was tested by trying to access both the buyer and seller "pathways" of the program through it.
- Screenshot:
- Description: This class allows the user to log in to the program or create a new account. By taking a
boolean isBuyerargument from the calling class, this class supports both buyer and seller logins. After a login is complete or the user has successfully created a new account (including compliance with the requirements of 6-character minimum usernames and passwords and a mandatory@symbol in the username), this class callsBuyerMenuGUIorSellerMenuGUIto continue the relevant pathway. This class also calls theServerCommclass (which, in turn, makesSocketcalls to theServerclass) in order to check login information and/or log the creation of a new account. - Testing: This class was tested by creating numerous accounts for both buyers and sellers. To ensure that error checking also works, invalid username/passwords inputs of all types (e.g. inputs that were too short or lacked required elements) were also tested.
- Screenshot:
- Description: This class allows the buyer to select transactions to perform after logging in. The buyer can select one of the following options by choosing the appropriate button, and the appropriate class will be started (and passed the main
JFrame, aJPanel, and aBuyerobject) to conduct that transaction: View Market, Dashboard, Shopping Cart, or Past Purchases. This class receives input of aJFrameand aJPanelfrom theLoginGUIclass, and thatJPanelforms the interface on which the buttons are drawn. - Testing: This class was tested by selecting each button and checking that the correct class was started. The class was also tested by clicking outside of the buttons and checking that no action occurred.
- Screenshot:
- Description: This class is analogous in functionality and appearance to the
BuyerMenuGUIclass, except that the following options are presented and aSellerobject is passed to the next class instead of aBuyerobject: View My Stores and Items, View Shopping Carts, View Past Sales, View Statistics, and Import/Export Products and Stores. - Testing: Like the
BuyerMenuGUIclass, this class was tested by selecting each button and checking that the correct class was started. The class was also tested by clicking outside of buttons to check that no action would occur. - Screenshot:
- Description: This class allows the user to view the market, purchase items, or add items to their cart. The class also provides searching, sorting, and refresh functionalities for the list of products. Upon selection of a product, a user is presented with the product information (i.e. name, price, store, seller, description, quantity available, and per-order limit) and offered the choice of whether to purchase the product, add the product to their shopping cart, or cancel the transaction. Upon selection of the purchase option, the user is prompted for input of a quantity that is then checked against the per-order limit and available quantity of the product. This class is called from (and returns to upon selection of the back button) the
BuyerMenuGUIclass, and this class also utilizes theServerCommclass to request the product list from theServerclass and to log new purchases and additions to the buyer's shopping cart. - Testing: This class was tested by creating multiple items from various sellers and attempting to purchase them/add them to the shopping cart from the
MarketGUI. The search functionalities of the class were also tested by using various sample search terms and checking that only relevant results appeared, while the sort functionality was tested by sorting the product list and checking that items appeared in the proper order. In order to test the error-checking functions of the class, invalid inputs (e.g. negative and zero quantities of products) were also used in all inputs. - Screenshots:
- Description: This class allows buyers to view the products in their shopping cart, remove items from their cart, and buy products from their cart. When a buyer chooses to buy a product from their cart, they are prompted for the quantity they want to purchase (which is checked for compliance with the available and maximum per-order quantities), and the item is removed from their cart. Like
MarketGUI, this class is called from theBuyerMenuGUIclass and utilizes theServerCommclass to communicate changes in the buyer's shopping cart and new purchases to theServerclass, which stores the changes in files. - Testing: This class was tested by adding various items to the shopping cart via the
Marketclass and checking if they appeared (with accurate information) in theBuyerShoppingCartGUIclass. Some of these products were then removed or purchased, and the main shopping cart was checked to see if these changes had been properly reflected. In order to test the persistence of changes, the buyer was also logged out and re-logged in to verify that changes made from the shopping cart page had not been lost. Invalid input was also tested by using the "Close" button on the quantity dialog and by trying invalid (i.e. negative, zero, or non-integer) inputs in the quantity to purchase. - Screenshots:
- Description: This class allows buyers to view their past purchases. Each purchase is displayed with the name of the item purchased, the total price of the purchase, the quantity purchased, and the name of the store. This class is called from the
BuyerMenuGUI, and this class calls theServerCommclass (which, in turn, communicates over aSocketwith theServerclass) in order to get the latest version of theBuyerobject whose purchases are to be viewed. - Testing: This class was tested by making various purchases from the
MarketGUIandBuyerShoppingCartGUIclasses and checking that they were properly reflected on theBuyerPastPurchasesGUIpage. - Screenshot:
- Description: This class allows buyers to view a list of all stores they have purchased products from and the quantity of items they have purchased from each store. The class also allows buyers to view a list of all stores that exist and the quantity of items that all users have purchased from each store. This class is called by the
BuyerMenuGUIclass and calls theServerCommclass to request the latest dashboard data from theServerclass via aSocket. - Testing: This class was tested by conducting various purchases from multiple user accounts and checking whether the numbers shown on the
DashboardGUIpage properly reflected these purchases (and that the individual buyer's statistics did not reflect purchases made by other buyers). - Screenshot:
- Description: This class allows sellers to view all of their stores, create new stores, delete stores, and create, view, edit, and delete products within each store. All of the seller's stores are initially displayed in a list once the class starts, each with buttons to "View/Modify Items in Store" or "Delete Store". If "View/Modify Items in Store" is selected, the user is given a choice of whether to create a new item, view/edit existing items, or to delete an item. If "Delete Store" is selected, the store is immediately deleted, as are all of its products. This class is called by the
SellerMenuGUIclass, and the class calls theServerCommclass as necessary to communicate changes in stores and items to the server. - Testing: This class was tested by using it to create various stores and products within those stores, before going back and editing, viewing, and deleting products and stores. In order to verify persistence of data entered via this screen, buyer accounts were used via the
Marketclass to verify that changes on this screen actually took effect. - Screenshot:
- Description: This class allows sellers to view the placement of their products in buyer shopping carts. For each buyer, this class displays each of the seller's products that are in the buyer's shopping carts (or displays that none of the seller's products are in the buyer's shopping cart). Additionally, the class displays the overall total number of the seller's products that are in all buyer shopping carts. This class is called by the
SellerMenuGUIclass, and the class calls theServerCommclass to request the latest version of multiple objects from theSeverclass over aSocketconnection. - Testing: This class was tested by adding items to various buyer shopping carts via the relevant classes and then checking whether the items were reflected on the
SellerShoppingCartGUIpage. The class was also tested by adding products from other sellers to buyer shopping carts and verifying that they did not appear on the first seller'sSellerShoppingCartGUIpage. - Screenshot:
- Description: This class allows sellers to view their past sales to all buyers. Each sale is displayed with the store name, item name, quantity of items purchased, total revenue, and the username of the buyer. The list of sales can also be refreshed using a refresh button. This class is called by the
SellerMenuGUIclass, and this class calls theServerCommclass (which make requests viaSockets to theServerclass) to get the latest sales statistics. Only the logged-in seller's sales are displayed in this class. - Testing: This class was tested by using various buyer accounts to buy a seller's products and then checking whether those purchases were properly reflected on the seller's
SellerSalesGUIpage. The class was also tested by purchasing items from other multiple sellers and verifying that each seller'sSellerSalesGUIpage only showed purchases from that specific seller. - Screenshot:
- Description: This class allows sellers to export products from and import products to their stores via a CSV file. To select a file to export products to or import products from, the user is shown a
JFileChooserand the returned file is opened and read from or exported to. If the stores in the CSV import file match stores that the seller actually has, the products will be imported to those stores. Otherwise, new stores will be created to accept the imported products. This class is called by theSellerMenuGUIin response to the user selecting theImport/Export Products and Storesoption, and this class calls methods in theServerclass via theServerCommclass in order to obtain data to export or to save imported data. - Testing: This class was tested by exporting various stores and re-importing them on different devices. This class was also tested by deliberately created improperly-formatted files (e.g. letters in numeric fields) and ensuring that the import would fail.
- Screenshot:
- Description: This class allows sellers to view summary statistics about sales of their items. Statistics are organized by store, with the class displaying the number of purchases and total revenue for each item in each of a seller's stores and the number of purchases and total revenue from each buyer for each of a seller's stores (representing that buyer's purchases of all products in the store). This class is called from the
SellerMenuGUIclass upon user selection of theView Statisticsoption, and the class calls methods in theServerclass viaServerCommto get the most recent sales statistics. - Testing: This class was tested by creating various stores and items in each store, buying those items from multiple user accounts, and checking that the purchases were properly reflected in the overall seller statistics on the
StatisticsGUIpage. - Screenshot:
- Description: This class allows client instances (i.e. instances of the
MenuGUIclass) to access and update the objects and data used throughout the program. This class also performs the program's data persistence functions by immediately saving each change that a client submits to a pair of data files (buyers.binandsellers.bin). TheServerclass is organized around a system of commands and responses sent and received via aServerSocket, all running on one thread per client. Each thread receives commands (i.e. integers and input objects in anObject[]) via theServerSocketfrom the clients connected to it, calls the relevant server methods, and returns the relevant data over theServerSocketvia anObjectOutputStream. Most client classes access this class via theServerCommclass, and this class makes up an integral part of program functionality. - Testing: This class was tested through general use of the program, which relies heavily on the class for nearly all functionality. For example, buyers and sellers were created, logged out, and then re-logged in -- operations that required methods in the server class. In order to test the concurrent elements of this class, IntelliJ's concurrent run feature was used to simultaneously run up to three client instances at once, and the propagation across all instances of changes in any single instance was visually checked.
- List of Commands: (in lieu of screenshots):
Buyer Commands:
0: Check a login to an existing buyer account
Input: String[] of email and password
Output: Buyer object (null if invalid login details)
1: Create a new buyer account
Input: String[] of email and password.
Output: Buyer object
2: Get market contents
Input: null object
Output: ArrayList<Item> of market contents
3: Update an existing Buyer object
Input: Buyer object
Output: null object
4: Log a sale
Input: Purchase object
Output: null object
5: Get dashboard data
Input: null object
Output: Object[] of two ArrayList<Strings> containing dashboard data.
6: Get the latest version of a buyer object stored on the server
Input: Buyer object
Output: Buyer object
7: Get the list of buyers
Input: null object
Output: ArrayList<Buyer> of buyers
Seller Commands:
30: Login to an existing seller account
Input: String[] containing email and password.
Output: Seller object
31: Create a new seller
Input: String[] containing email and password.
Output: Seller object
32: Update a Seller object
Input: Seller object
Output: null object
37: Get shopping carts containing a seller's products
Input: Seller object
Output: ArrayList<String> of shopping cart information.
38: Get the seller's past sales
Input: Seller object
Output: ArrayList<Purchase> of past sales.
39: Get the latest server-side version of a Seller object
Input: Seller object
Output: Seller object (updated)
40: Get the seller statistics view data
Input: Seller object
Output: Object[] of four arrays: ArrayList<String> of sales statistics by store, ArrayList<String> of sales statistics by buyer, ArrayList<Integer> of number of sales by store, and ArrayList<Integer> of nums of sales by buyer.
41: Get the seller list
Input: null object
Output: ArrayList<Seller> of sellers
- Description: This class allows client instances to make commands to the
Serverclass by creating aSocketto the server and using anObjectOutputStreamand anObjectInputStreamover thatSocket. This class is called by most client classes and serves as the exclusive method for other client classes to access and modify data on the server component. - Testing: This class was tested by running numerous commands through it in the course of normal program operation. The class was also tested with sudden disconnects and reconnects to ensure that these potential errors would not result in data loss or a program crash.
- Screenshots are not relevant for this class.














