<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I just have a general question about the observer portion of lab 12.</div><div><br></div><div>Instructions:</div><div><div>Extend your program as follows. In "Coffee Shack", the barista takes the customers' order and then prepares their drunks. </div><div>The barista may serve her customers concurrently. Once the drink is ready, the customers are notified. </div><div>Specifically, after taking an order, the barista randomly either notifies all customers that one of the drinks is ready, the drinks may not necessarily be prepared in the FIFO order, or starts taking a new order. </div><div>Code the service of "Coffee Shack" using Observer Design Pattern. </div><div>Customer objects should be registering with Barista object and being notified when a drink is ready. </div><div>All customers could be notified at once. Then, each customer should determine if it is her drink.</div></div><div><br></div><div>My issue:</div><div>I am not sure how to delay the creation of drinks.</div><div><br></div><div>Upon taking an order, should the Barista create the appropriate drink object and store it until all customers are notified, or should the creation of the drink object be delayed?</div></div></blockquote><div> </div><div>Upon taking an order, the barista may choose to take another order or prepare drink (probabilistically). This is why you need a vector/queue of order. The pseudocode can be:</div><div><br></div><div>while(true)</div><div>{</div><div> //Take an order or prepare a drink randomly. If there is no order in the queue, take new order.</div><div><br></div><div> //If barista prepared the drink, notify all the customers immediately using observer pattern (You can use push or pull method as you wish) <br></div><div>}<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Should the Barista have a vector of drinks? </div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Specifically, I am struggling with these:</div><div>1) The barista may serve her customers concurrently<br></div><div><br></div><div>2) Specifically, after taking an order, the barista randomly either notifies all customers that one of the drinks is ready, the drinks may not necessarily be prepared in the FIFO order, or starts taking a new order. <br></div><div><br></div></div></blockquote><div><br></div><div>No, the Barista should have a vector of Order (Drink+customer Name)
instead. Every time he takes a new order, the order should be added to
the vector. If he choose to prepare a drink, he picks an oder from the
vector (in FIFO order or not. You can implement the ordering as you like). <br></div><div><br></div><div>Please let me know if this is not clear. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Hopefully I have described my issue with enough detail.</div><div>I appreciate any help you can provide.</div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div></font></span></div></blockquote></div><br clear="all"></div><div class="gmail_extra">Thanks<br></div><div class="gmail_extra"><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-size:small;font-family:arial">Tamim</div><span style="font-size:small;font-family:arial">PhD Candidate</span><span style="font-size:small;font-family:arial"></span>, <br>Kent State University<br><div style="font-size:12.8px"><font size="2" face="arial"><a href="https://web.cs.kent.edu/~mislam4/" target="_blank">http://web.cs.kent.edu/~mislam4/</a></font></div></div></div></div></div>
</div></div>