Search for question
Question

Question 2) Thread: a mobile phone virus transmission simulation (50%) You need to design a virus transmission simulation. You are going to draw some icons instead of mobile phones in your simulation. The number of mobile phones can be increased during the simulation by clicking a key from a keyboard. Each phone runs as a thread. A virus starts in a random phone, and it transmits to the others in the range of 20 pixels. Infected phone needs to take to a repair shop to get repaired. Only one phone can be repaired at a time. You need to design and write "synchronized" algorithm to handle it. If the phone cannot be repaired within 500 frames, the phone will die (the phone is removed from the simulation). Design YOUR OWN GUI of the simulation. ⚫ Phone's behaviours • 。 You may use the linked list from question 1 to store all the phones or you may use array to store all the phones. 。 Mobile phones are drawn on the simulation application. (3%) o Repair shop is drawn. (3%) 。 Mobile phones move randomly (2%) ° Each phone runs as a thread. (5%) ° An "up" arrow key is used to increase the number of phones in the simulation. (3%) 。 Different colours for three different states of a phone (health phone, infected phone and moving to repair shop). You choose your own colour for the phones. (2%) o Press "v" key to set one phone to get virus randomly. (2%) The virus transmits through network within a certain distance (distance is about 20 pixels in this simulation) (3%) After a phone get infection, simulation counts down the life span of the phone from 500 to 0. When it gets to 0, the phone will be removed from the simulation. (2%) Synchronized 。 You can synchronize your block of code or method. (5%) 。 only one phone is in the repair shop at a time. (NO race conditions) (5%) You need to select an object for synchronize. (5%) 000 Answer the following question as comments in your Phone class (put question and your answer on the first line of your code). (8%) Question: "Which object(s) have you chosen for the synchronize? Why?"

Fig: 1