<aside> 🛒 Simulate a grocery store with customers, checkout registers, and queues using linked lists. The simulation allows you to create customers, and open/close registers. Implement both single and multiple queue systems.
</aside>
getMode() function
: This function retrieves the mode of the queueing system based on the user input. The mode can be 'single' or 'multiple'. In a 'single' mode, there's only one queue for all registers. In 'multiple' mode, each register has its own queue.parseRegisterAction()
, openRegister()
, and closeRegister()
functions: These functions parse the commands related to checkout registers. They handle user commands to open and close registers within the simulation.
parseRegisterAction()
function determines which action to take concerning the registers (whether to open or close).openRegister()
function processes commands to open a new register.closeRegister()
function processes commands to close an existing register.addCustomer()
function: This function interprets the commands that add customers to queues. It takes details about the customer and assigns them to the appropriate queue based on the simulation mode.getInt()
and getDouble()
functions: These functions parse integer and double values from the user input, ensuring that numerical data such as the number of items or time is correctly interpreted by the program.foundMoreArgs()
function: This function checks for command syntax errors, specifically if more arguments were provided than expected. It helps maintain the integrity of the command parsing process.The commands accepted by the starter code follow a specific format where:
register open
followed by specific parameters: the ID of the register, the seconds per item, the setup time, and the time elapsed since the last action.register close
followed by the register's ID and the time elapsed since the last action.customer
followed by the number of items the customer has and the time elapsed since the last action.Here's what each parameter represents:
<ID>
: The identifier for a register.<secPerItem>
: The time in seconds it takes for the register to process one item.<setupTime>
: The time it takes to set up a register for a new customer.<items>
: The number of items a customer has.<timeElapsed>
: The simulated time that has passed since the last command or action.