Queue/Usage: Difference between revisions

no edit summary
(→‎{{header|Delphi}}: Adds Déjà Vu example)
No edit summary
Line 127:
(*1*)
</pre>
 
=={{header|App Inventor}}==
This Rosetta Code Task requires that the queue operations of push (enqueue), pop (dequeue) and empty be demonstrated with App Inventor.<br>
This is easy to do as those operations are basically available in a slightly different form as list operations.<br>
In addition for this example, I added a top function to view the first item in the queue.<br>
<br>
The solution is a complete (although greatly simplified) hamburger restaurant where the customers and orders are the queues.<br>
 
Customers enter the restaurant at random intervals between 2 and 10 seconds (Customers Clock Timer)<br>
Each customer will request a random item from the menu.<br>
If the item is not available, the customer leaves.<br>
If that item is available (there are only 30 of each item) then the order is placed and payment is accepted (push|enqueue Customer, push|enqueue Order).<br>
Once an order is placed, the customer must wait for the meal to be prepared -- each menu item takes a different number of seconds to prepare (Orders Clock Timer.)<br>
Once the item is prepared, their customer name and the ordered item are removed from the queues (pop|dequeue Customer, pop|dequeue Order).<br>
If there are no pending orders, (empty Orders queue) the cook just waits for one to be placed (the orders clock continues to run to poll for new orders by testing if the Orders queue is not empty.)<br>
Eventually, all items will have been sold, and the store manager will empty the cash register and fly to Tahiti with the waitress.<br>
The eager -- but destined to be frustrated customers -- will continue to request their random items, forever. :)<br>
[https://lh6.googleusercontent.com/-dTvs9totvDE/Uu3ZiFeE90I/AAAAAAAAJ-w/lJBVHOd-p0g/s1600/Untitled.png CLICK HERE TO VIEW THE CODE BLOCKS AND ANDROID APP SCREEN]
---
END
 
=={{header|AutoHotkey}}==