NB: Working repository is still private, this repository was made public with permission from all who worked on the original project and contains the latest stable version of the program
.jar with latest build can be found in "Builds" folder
Welcome to the L&R^2 Bakery Inventory System! This system helps manage the inventory of various bakery products, including adding new orders, deliveries and managing the inventory through a simple graphical user interface (GUI). This document will guide you through the different sections and functionalities of the system.
The system allows users to:
- View Inventory: The inventory of bakery items can be accessed and updated.
- Add Orders: Orders can be placed and processed.
- Add Deliveries: Deliveries to restock inventory can be entered.
- Save Data: Changes made to the inventory and orders are saved to files for persistence.
Login.java
- A login dialog was implemented using
JDialogto ensure only authorized users can edit inventory items. - The interface includes:
- Username and password fields
- Login and cancel buttons
- Message label for login feedback
- Credentials are stored in a
.datfile (login.dat) for basic obfuscation and are read during authentication. - If the file does not exist, default credentials are created:
- Username:
CookieMonsta - Password:
ILuvCookies
- Username:
EditButtonListenerclass inListInventory.java- Before the edit popup appears, the system:
- Prompts the user with the login dialog
- Grants access only if credentials are valid
- Shows an error message if login fails or is cancelled
-
View and Edit Inventory: The system loads inventory items from a file (
inventory.txt). The inventory includes various baked items such as Bread, Brownies, Cake, Cookies, Cupcakes, Danish, and Donut. The inventory is updated whenever a delivery is made or an item is ordered. -
Low/Overstocked Alert Feature [Using Custom Cell rendering for JTable]
- When there are less than 5 items the items are highlighted in red on the table for ease of viewing.
- When there are more than 50 items the items are highlighted in green on the table for ease of viewing.
-
Pie Chart Visualization
- Pie chart generated for ease of viewing distribution of stock.
-
File Persistence: Inventory data is saved to a file named
Inventory.txt. This ensures that all changes to the inventory are stored even after the program is closed.
- Orders: Orders can be placed for different bakery items. When an order is placed, it is added to the
OrderListand saved to a file (orders.txt), ensuring that all orders are stored. - Order ID: Each order has a unique ID, which is managed automatically by the system.
Order Class
- The
Orderclass is responsible for managing individual orders in the system. - Fields:
id: A unique identifier for the order, which is automatically incremented with each new order.itemName: The name of the ordered item.quantity: The quantity of the item ordered.
- Constructor: The constructor takes the
itemNameandquantityas parameters, assigns the uniqueidto the order and increments thenextIdfor future orders. - Methods:
getItemName(): Returns the name of the item ordered.getQuantity(): Returns the quantity of the item ordered.toString(): Provides a string representation of the order in a comma-separated format, which is useful for saving the order to theorders.txtfile.setNextId(): Sets the next order ID to ensure that each order has a unique ID.
The Add Delivery functionality allows users to restock inventory by entering a delivery. This functionality is facilitated by the AddDelivery class, which provides a simple GUI to add a delivery to the system.
- The
Deliveryclass represents a delivery made to restock inventory. - Fields:
id: A unique identifier for the delivery, automatically incremented with each new delivery.itemName: The name of the item being delivered.quantity: The quantity of the item being delivered.
- Constructor: The constructor takes the
itemNameandquantityas parameters, assigns the uniqueidto the delivery and increments thenextIdfor future deliveries. - Methods:
getItemName(): Returns the name of the item delivered.getQuantity(): Returns the quantity of the item delivered.toString(): Provides a string representation of the delivery in a comma-separated format for file saving.setNextId(): Sets the next delivery ID, ensuring each delivery has a unique ID.
- Select Item: From the dropdown menu, select the item being delivered (e.g., Bread, Brownies, etc.).
- Enter Quantity: Enter the quantity of the item being delivered using the spinner widget.
- Save Delivery: Press the Save button to save the delivery, update the inventory and write the changes to the file.
- Cancel Delivery: If you wish to cancel the delivery, press the Cancel button.
The InventoryItem class is used to represent an individual item in the inventory. Each item has a unique ID, a name and a quantity. The items in the inventory are stored in a list and can be sorted by id or quantity in ascending order.
- Fields:
name: The name of the inventory item (e.g., Bread, Cake, Brownies).quantity: The quantity of the inventory item available.id: A unique identifier for each item in the inventory. This ID is immutable after it is set during object creation.
- Constructor: The constructor initializes an
InventoryItemobject with thename,quantityandidof the item. - Methods:
getName(): Returns the name of the item.setName(): Allows setting a new name for the item (though this is generally not necessary for inventory management once items are added).getQuantity(): Returns the quantity of the item available in the inventory.setQuantity(): Allows setting a new quantity for the item (useful for updating inventory when deliveries are made or orders are placed).getId(): Returns the unique ID of the item.- compareTo(): Implements the
Comparableinterface to allow sorting inventory items by their unique ID. The comparison is made in reverse order (smaller IDs come first). toString(): Provides a string representation of the inventory item in the format:"ID: {id} | Name: {name} | Quantity: {quantity}".
- This class provides the functionality to add a delivery and update the inventory accordingly.
- UI Components:
- Item Dropdown: Allows the user to select the item being delivered.
- Quantity Spinner: Allows the user to specify the quantity of the item being delivered.
- Save and Cancel Buttons: Save the delivery or cancel the operation.
- saveDeliveriesToFile(): Saves the details of the deliveries made to a file named
deliver.txt. - saveUpdatedInvToFile(): Saves the updated inventory to a file (
Inventory.txt). - UpdInv(Delivery delivery): Updates the inventory by adding the quantity of the delivered item to the current stock.
- The main class serves as the entry point to the application. It initializes the system, loads the inventory, orders, and deliveries and sets up the GUI.
- init(): Initializes the inventory from the
inventory.txtfile and ensures that any missing inventory files are created. - loadOrders(): Loads existing orders from the
orders.txtfile. - loadDeliveries(): Loads previous deliveries from the
Delivery.txtfile. - SwingUtilities.invokeLater(): Launches the GUI on the event dispatch thread.
The system reads and writes the following files to store data:
- Inventory.txt: Contains the inventory of bakery items. Each line consists of an item’s ID, name and quantity.
- Orders.txt: Stores the orders placed by customers, with each line containing an order's ID, item name and quantity.
- Delivery.txt: Stores the deliveries made to restock inventory. Each line contains a delivery's ID, item name and quantity.
- login.dat: Used to store and verify Login details.
The system provides a simple GUI for interacting with the inventory and adding orders or deliveries. The GUI is built using Java's Swing library, and it includes the following components:
- JComboBox: For selecting the item being delivered.
- JSpinner: For selecting the quantity of the item being delivered.
- JButton: For saving or canceling actions.
- JLabel: For displaying text information (e.g., labels for item and quantity).
This system simplifies bakery inventory management by automating the process of adding orders, deliveries and inventory updates. By utilizing a GUI and maintaining persistent data through file storage, it offers an easy-to-use solution for bakery operations.