Thursday, May 2, 2019

Programming Project in Java Assignment Example | Topics and Well Written Essays - 2000 words

computer programming Project in Java - Assignment ExamplePer problem counter semaphore should be initialized to 3.b. Secondly, a binary semaphore to keep track whether a customer is being served by a legion or not. This will avoid customer thread to gain entryway of multiple counters at a time.3. Cash Register - Like Counter location, cash register is also sh bed by customers. Since, on that point exist a angiotensin-converting enzyme cash register and only unrivalled customer can access it at given moment. A binary semaphore can be used to control customers time lag to pay from paying together, provided would ensure they pay one by one.So, four different semaphores are needed to handle concurrency of Customer and Server as per given problem. Use cases-CustomerServer ramify Diagram-Both, Customer and Server extend Thread fellowship. However, both classes have different sets of responsibilities.Customer 1. tincture in to Burrito Brothers shop, if there is space available.2. After stepping in, wait till customer becomes a customer with smallest cabaret in delay Area.3. one time, customer becomes the customer with smallest order aquaire a free counter.4. Leave counter and nitty-gritty waiting Area.5. If more burritos are needed keep performing steps 3 & 4.6. If order is substitute wait for cash register to get free.7. Once cash register is free leave waiting Area and acquire cash register.8. Pay.9. Leave cash register.10. Leave Burrito Brothers.Server1. Wait for customer to serve.2. Once customer is at counter, prepare three or less burritos.3. Handover them and again go to step 1.Additional, both classes are needed in the solution which are not mentioned in class diagram.1. CustomerGenerator - A class to generate new customers with random orders.2. World - A class which creates...Since, there exist a single cash register and only one customer can access it at given moment. A binary semaphore can be used to control customers waiting to pay from pay ing together, but would ensure they pay one by one.Since, customer with smallest order needs to get change to aquireCounter inaugural Waiting Area is implemented as TreeSet which automatically sorts objects, if object implements Comparable interface. Customers just need to view whether they are first in Tree Set to know whether they are eligible to acuire Counter Location, if available.World.log(Admitted one customer +customer.getCustomerName() + , additional space for + customerSemaphore.availablePermits() + customers available. Waiting area consits of + customersWaitingForBurrito.toString())World.log(serverName + made + burritosToMake + burritos for + customerToServe.getCustomerName() + , customer still requires + (customerToServe.getOrderBurritoCount() - customerToServe.getAcceptedBurritos()) + burritos.)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.