Individual Assignment (System) Week 14
Individual Assignment (System) Week 14
Objective:
This assignment has been designed for students to apply appropriate concurrent program
methods in implementing a concurrent program from a program specification.
Learning Outcomes
PLO2 Cognitive Skills - This relates to thinking or intellectual capabilities and the ability to apply
knowledge and skills. The capacity to develop levels of intellectual skills progressively begins
from understanding, critical/creative thinking, assessment, and applying, analysing, problem
solving as well as synthesizing to create new ideas, solutions, strategies, or new practices. Such
intellectual skills enable the learner to search and comprehend new information from different
fields of knowledge and practices.
Page 1 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2
Submission Requirements:
Assignment Handout Date : 29th November 2023
Case Study
• When the baristas are asleep, the baristas waits to be awakened by a new customer. (Any
available baristas can be told to wake up if multiple baristas are asleep.)
• The barista requires the espresso machine and milk frothing machine to prepare a
cappuccino which costs RM9.
Page 2 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2
• The barista requires the espresso machine to prepare an espresso which costs RM6.
• The barista requires the juice tap to prepare a juice drink which costs RM7.
• Customers pay upon ordering and collect their drinks when ready.
• All customers consume their beverages in the café. No takeaways are assumed for this
simulation.
• When the customer first enters the cafe, the customer leaves immediately if more than 5
people are waiting. On the other hand, if the cafe is not too full, the customer enters and
waits.
• If all baristas are busy, the customer stands in line to make an order.
*****************************Additional Requirements****************************
Customers keep track of their arrival, so the person waiting the longest is always the next
customer to get a drink.
Similarly, standing customers remember their order, so the person standing the longest takes the
next available seat.
Some customers do not like to share a table with strangers. They will wait for a table to become
available for a certain amount of time, before willing to share a table with strangers.
The cafe should close after all customers have left and all baristas are sleeping.
Customers drink preparation progress should be seen.
Customers drinking progress should be seen.
Which machines are used by which barista should be clearly stated.
Espresso machine, milk frothing machine, and juice tap availability should be stated when
baristas attempt to acquire.
Each event should take some time.
70% of customers order Cappuccino, 20% order Espresso, and 10% order Juice.
Total number of each drink and sales for the day should be reported.
*****************************************************************************
Extra points: Some customers who are standing get tired after a while and leave the cafe.
Deliverables:
For this exercise, you are to model the cafe and write a Java program to simulate activity for
this cafe:
Page 3 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2
Sample Output
In order to see what is happening dynamically you must have output from the Customers and
the barista reporting all their major events.
Add information about which process/thread is doing the output. This way you can see if a
process/thread acts for another, which is strictly forbidden, but is a common error for Java
solutions (objects are not processes!). An example of such incorrect behaviour is
Thread-Barista1: 21.31: Barista1: Espresso for Customer 3 is done!
main: 21.50: Barista1: Next customer please!
Thread-Customer-12 : 21.50: Customer12 is waiting for a chair.
Thread- Barista1: 21.51: Barista1: Acquiring Juice Tap!
Where you can see that not only the Barista1 thread but also the main thread is acting for the
Barista.
Note that realistic time stamps are not required, it is fine to use any function to generate them.
You must not
• Kill a thread or process. You may not use any of the following in Java:
o Thread.stop
o Thread.resume
o Thread.suspend
o Thread.interrupt
o setDaemon
If any of those primitives are found in your code, you will fail the assignment no matter
the functionality of it.
Page 4 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2
Implementation
Page 5 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2
Report (20%)
Criteria Total marks Marks
awarded
Assumptions [LO3-PO6] 20
Explanation of the safety aspects of multi-threaded system 30
implemented [LO3-PO6]
Justification of coding techniques implemented [LO3-PO6] 30
Depth of discussion of concurrency concepts [LO3-PO6] 20
TOTAL MARKS 100
System (25%)
Criteria Total marks Marks
awarded
Appropriateness of coding techniques used to implement 20
design with appropriate comment lines in source codes *
Appropriateness of the Java concurrent programming facilities 20
used.
Program runs appropriately with basic requirements * 20
Additional requirements met * 20
Explanations of concurrency concepts implemented with 20
relevant code samples *
TOTAL MARKS 100
Page 6 of 6