{"id":27132173,"url":"https://github.com/alaszmigiel/supermarket-simulation","last_synced_at":"2026-04-27T00:32:08.213Z","repository":{"id":286689644,"uuid":"952547268","full_name":"alaszmigiel/Supermarket-Simulation","owner":"alaszmigiel","description":"Supermarket simulation managing customer and cashier interactions with queues, breaks, and shift changes. Animated in real-time using JavaFX.","archived":false,"fork":false,"pushed_at":"2025-07-03T08:30:52.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-28T22:06:36.210Z","etag":null,"topics":["cashier","customer","java","javafx","multithreading","queue","simulation","synchronization"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alaszmigiel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-21T13:13:31.000Z","updated_at":"2025-07-03T08:30:56.000Z","dependencies_parsed_at":"2025-04-07T21:52:45.966Z","dependency_job_id":"889325c4-2d2d-4ec2-8136-e0f24b7faa10","html_url":"https://github.com/alaszmigiel/Supermarket-Simulation","commit_stats":null,"previous_names":["alaszmigiel/supermarket-simulation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alaszmigiel/Supermarket-Simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaszmigiel%2FSupermarket-Simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaszmigiel%2FSupermarket-Simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaszmigiel%2FSupermarket-Simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaszmigiel%2FSupermarket-Simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alaszmigiel","download_url":"https://codeload.github.com/alaszmigiel/Supermarket-Simulation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaszmigiel%2FSupermarket-Simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32318417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"ssl_error","status_checked_at":"2026-04-26T23:26:25.802Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cashier","customer","java","javafx","multithreading","queue","simulation","synchronization"],"created_at":"2025-04-07T21:52:31.740Z","updated_at":"2026-04-27T00:32:08.207Z","avatar_url":"https://github.com/alaszmigiel.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Supermarket Simulation\nThis project simulates operations of a supermarket with multiple cash registers, where **customers** interact with **cashiers** in real-time. \nCustomers select the shortest queue, wait for their turn, and are served by cashiers. \nThe system manages **cashier breaks**, **shift changes**, and synchronizes all processes using **monitors** and **locks** to ensure smooth operation and avoid conflicts when accessing shared resources.\n\n\n## Key features \n- ***Customer Process***:  The customer enters the supermarket, selects the shortest queue, and waits for their turn to be served.\nAfter being served by a cashier, the customer process completes. Customers are visualized as moving circles, which change colors when being served.\n- ***Cashier Process***:  Cashiers serve customers from their respective queues.\nAfter serving customers for a specified period, cashiers can request breaks or shift changes. When this happens, the register temporarily closes, and the queue is blocked for new customers.\n- ***Animation***:  Using **JavaFX**, the simulation provides a dynamic visualization of customers and cashiers interacting in real-time.\nCash registers are represented as rectangles, and customers as moving circles, with color changes reflecting different statuses (open, on break, closing, etc.).\n- ***Synchronization and Thread Management***: The simulation uses **locks** to ensure that resources like queues and cashier operations are accessed in a thread-safe manner, preventing race conditions and ensuring smooth operation. \n\n## Project Structure\n```sh\nSupermarketSimulation/\n│── src/main/                    \n│   ├── java/com/supermarketsimulation/  \n│   │   ├── Client.java                 # Represents a customer \n│   │   ├── Cashier.java                # Represents a cashier and handles operations (serving, breaks, shifts)\n│   │   ├── CashRegistersMonitor.java   # Manages the state of all registers and queues\n│   │   ├── SupermarketController.java  # Controls simulation logic\n│   │   ├── Main.java                   # Main class to start the simulation \n│── resources/com/supermarketsimulation/  \n│   ├── SupermarketLayout.fxml          # JavaFX layout for the simulation interface\n│── .gitignore                         # Files and directories to be ignored in version control\n│── pom.xml                            # Maven project configuration\n│── README.md                          # Project documentation (this file)\n```\n\n## Technical Requirements \n- Java 21 or higher\n- Maven\n- JavaFX\n\n## Installation \u0026 Usage\n\n### 1. Clone the repository:\n```sh\ngit clone https://github.com/alaszmigiel/Supermarket-simulation.git\ncd Supermarket-Simulation\n```\n\n### 2. Build the project:\n```sh\nmvn clean install\n```\n\n### 3. Run the simulation:\n```sh\nmvn javafx:run\n```\n\n## Shared Resources \u0026 Synchronization:\nThe simulation relies on several shared resources that are synchronized:\n- **Customer Queues**: Each register has its own queue, and the system uses locks to manage safe access to these queues and prevent race conditions.\n- **Cash Registers and Operations**: System makes sure that operations like **breaks** and **shifts** are synchronized, and register status changes are handled without conflicts.\n- **Synchronization Objects**:\n  - **Local Locks**: Each customer queue is protected by a dedicated lock to have thread-safe access.\n  - **Global Lock**: A global lock is used for operations that affect multiple queues or the overall system.\n\n## Simulation Workflow\n- ***Customer Process***: Customers enter the store, choose the shortest queue, and wait to be served.\nAs they are served, their circle in the animation turns **green**. Once served, the customer process ends.\n\n- ***Cashier Process***: Cashiers serve customers from their respective queues.\nAfter a set time, the cashier may **request a break**, which turns the register color to **yellow**.\nCashier must wait in line for their turn to take a break and when he becomes first it will be approved when no other cashier is currently on break and no other cashier\nis in the process of switching shifts.\nOnce a **break request is approved**, the register color changes to **orange**, and the queue is temporarily blocked from accepting new customers.\nWhen a cashier returns from their break, the register color turns green, signaling it is open again.\n\n- ***Shift Change***:\nAfter returning from their break, the cashier may **request a shift change**. Register color then turns **dark blue**. A shift change is only allowed if\ncashier is the first in line for a shift change and no other cashier is currently changing or on break\nOnce all customers in the queue are served, the register color changes to **light blue**, meaning that a new cashier will take over the register.\n\n- ***Store Closing***: Once all customers have entered the store, the registers turn light gray, signaling that the store is closing.\nAfter all customers have been served, the register turns **dark gray**, marking the end of the simulation.\nAt this point, no further break or shift requests can be made, and all cashiers finish their work.\n\n### Simulation States:\n- **Register States**:\n  - **Green**: Register is open and serving customers.\n  - **Yellow**: Cashier has requested a break.\n  - **Orange**: Register is closing, serving last customers.\n  - **Red**: Cashier is on break.\n  - **Dark Blue**: Cashier has requested a shift change.\n  - **Light Blue**: Register is closed for a shift change, and a new cashier takes over.\n  - **Light Gray**: All customers have entered the store, store is closing.\n  - **Dark Gray**: Register is closed, no more customers to serve.\n- **Customer States**:\n  - **Black**: Customer is choosing a queue or waiting in line.\n  - **Green**: Customer is being served.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaszmigiel%2Fsupermarket-simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falaszmigiel%2Fsupermarket-simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaszmigiel%2Fsupermarket-simulation/lists"}