Vending Machine
A vending machine that sells different types of snacks, can be paid by cash or card. Different roles can log in and manage users, products, cashes, depending on their permissions.
How to run the program
First, you have to set up the connection to the MySQL database in src/main/java/VendingMachine/DatabaseHandler.java
. You can import the sample database Vending_Machine.sql
.
Then, you can use gradle build
first to build the program. After that, you can use gradle run
to run the program.
NOTE: If you run the test, it will restore all resources to the initial state for a uniform testing environment. All changes on users, cashes or products will lose.
NOTE: gradle build
will run the tests automatically. If you want to build the program again but want to keep the resources, please use gradle build -x test
to exclude testing. Or if you just want to run the program again, please use gradle run
.
In progress
I'm working on using MySQL to manage database instead of csv.
-
Cash system can support MySQL
-
Product System
-
Card System
-
Transaction System
-
User System
Usage
blan
is an owner. Its password is 123
. Feel free to use this account to test functionalities.
One of credit cards has name Charles
and card number 40691
. Feel free to use this card to test functionalities.
Sign In or Sign Up
At first the window will display the current user is anonymous
by default.
After click on Account
button, it display a window to sign in or sign up.
When it sign in with correct username and password the main window will display corresponding username and its type on the top right corner, as well as the text on button will change to Logout
instead of Account
.
When it sign in with wrong username or password, it will display an alert to notify user it has wrong username or password.
Shopping Cart
Display Product
The Product table on default page is available for every user include all the products that the machine has.
Display cart
The cart display on product table on default page is available for every user include all the products were selected by current user.
Add to Cart
The user can select which product he want to add to cart, then click the row which the product is, after that this product's name will be automatically filled in the item name field, then choose the quantity he want. After that click on Set Qty in cart
button. The cart table will update accordingly.
Remove Cart
The user can select which product he want to remove, then click the row which the product is, then choose the quantity he want to remove. After that click on Set Qty in cart
button. The cart table will update accordingly.
Purchase Item
Checkout Window
The Checkout window is available for every users. If current cart table has nothing, after click Checkout
button, it will display an alert to notify current user have no item to purchase.
After click Checkout
button, there is a window display items' amount in cart. Besides, there are three more operations, card, cash or cancel. And in the middle there is 120s countdown, when it comes to 0, it will automatically back to default window, and record this transaction to be cancelled with reason "timeout".
Card Payment
After click the Card
button, it need user input card name and number. Besides, there are two more operations, check and pay. And in the upper left corner there is 120s countdown, when it comes to 0, it will automatically back to default window. And in the lower left corner, user can tick to save the card information or not.
User input the name and number of the card he want to pay this transaction.
If user save the card before, System will automatically filled the information.
After click the Cancel
button, it will back to default window and record this transaction to be cancelled with reason "user cancelled".
Check card
After click the check
button, if the card information is incorrect, it will display an alert notify current user the card is wrong. If the information is correct, this transaction is succeeded.
If the user tick the Save card
and click Check
button. if user is anonymous, it will display an alert to notify user is anonymous which does not right to save the card.
Cash Payment
After click the Cash
button, there is a table include the cash's value and number. Besides, there are two more operations, set, pay and cancel. In addition, in the upper left corner there is 120s countdown, when it comes to 0, it will automatically back to default window, and record this transaction to be cancelled with reason "timeout".
Set Cash to Pay
The user can input cash type and its amount. Then click theSet
button, after that the table will update accordingly.
Pay
If user didn't add any cash. It will display an alert to notify current user doesn't pay any cashes.
After click the Pay
button. There is a table of change include different values and amount. The cash in the machine also will be reduced accordingly.
If user didn't pay enough money to purchase, it will automatically cancelled this transaction with reason "no enough money paid".
If vending machine does not have enough money to give back change, it will also automatically cancelled this transaction with reason "no available changes".
Display Information
Display the latest 5 Products
The latest bought items table on default page is available for every user. If you have login, it will show your purchase history, else it will show the anonymous' last 5 bought items.
Display Sold History
The sold history window is only available for owner and seller users. If current user is not them, it will display an alert to notify current user have no access to this feature.
After click the Sold History
button. There is a table of all the product that have been sold in the system.
Display Transaction History
The Transaction History window is only available for owner and cashier users. If current user is not owner or cashier, it will display an alert to notify current user have no access to this feature.
After click the Transaction History
button. There is a table of transactions that includes transaction date and time, item sold, amount of money paid, returned change and payment method. Besides, there is one more operation, view transaction product history.
The owner can select which history he want to view, then then click on View details
button. There is a table of all products sold in this transaction include name, category, price and quantity.
Display Cancelled History
The user management window is only available for owner users. If current user is not owner, it will display an alert to notify current user have no access to this feature.
After click the Cancelled History
button. There is a table of cancelled transaction during this system includes date and time of the cancelled, the user and the reasons.
Generate Report
After click the Generae Report
button. There are some operations which can generate different report . After click these buttons, a new folder called report
will be created, and then according to different permissions, different csv reports can be generated in the report
folder.
User Management
Display Users
The user management window is only available for owner users. If current user is not owner, it will display an alert to notify current user have no access to this feature.
After click the Manage User
button. There is a table of all the users that have been registered in the system. Besides, there are three more operations, add or change or remove users, that owner have access.
Add Users
The owner can input new username, password and user type, then click on Add
button. The table will update accordingly.
If owner does not input full relevant information then click on Add
button, it will display an alert to notify current owner to fill in the missing information.
Change Users
The owner first need to select which users he want to change, then click on the row where the user is, then the relevant information of this user will be automatically filled in the information field, then edit the username, password or user which users want to be change, then click on Change
button. The table will update accordingly.
Remove Users
The owner can select which users he want to remove, then click the row which the user is, after that this user's relevant information will be automatically filled in the information field, then click on Remove
button. the table will update accordingly.
Cash Management
Display Cash
The cash management window is only available for owner and cashier users. If current user is not them, it will display an alert to notify current user have no access to this feature.
After click the Manage Cash
button, there is a table has all types of cash exist in Australia. Besides, there are one more operation change the number of the value.
Change Cash
The user can select which value he wants to change, then click the row which the value is, after that the relevant information of this value will be automatically filled in the information field. Input the new number which the user want, then click the Change number
button. The table will update accordingly.
If the user input symbol or letters. An alert box will notify it is fail to change.
Product Management
Display Product
The product management window is only available for owner and seller users. If current user is not them, it will display an alert to notify current user have no access to this feature.
After click the Manage Product
button, there is a table of all the products that the machine has. Besides, there are three more operations, add or change or remove products.
Add Product
The user can input new code, Name, Price and Quantity, then click on Add
button. An alert box will notify it is successfully added and the table will update accordingly.
If users input the repeated code or name then click on Add
button, it will display an alert to notify current user the product exists in the system.
Change Product
The user first need to select which product he want to change, then click on the row where the product is, then the relevant information of this product will be automatically filled in the information field, then edit the code,name,price,quantity and category which user want. then click on Change
button. The table will update accordingly.
If user input invalid price like lettes or symbols. An alert box will notify it is failed changed.
Remove Product
The user can select which product he want to remove, then click the row which the product is, after that this product's relevant information will be automatically filled in the information field, then click on Remove
button. The table will update accordingly.