The Sky-blue and the gnomes project in Java | Java Assignment | Java Homework

Once upon a time, there was a princess named Sky-blue. The princess’s stepmother, the Queen was very mean and vain. She was jealous because she wanted to be known as "the fairest in the land," and Sky-blue’s beauty surpassed her own. One day, Sky-blue couldn’t take it anymore and run away to a fairy garden. In the garden, she found a small cabin. In the cabin, there were num_gnomes little beds, one table of table_size size, one love seat, one recliner and a big 50” flat screen TV. However, the cabin was very dirty and failed to provide a pleasant environment to relax and watch a good movie.
Sky-blue decided to start cleaning and cooking. Soon she got exhausted and fell asleep (use wait)

In the evening, the gnomes arrived home from the diamond mine. They computed in different ways (sleep of random time) but they always waited for each other, so that all of them should be at the door before entering the cabin. The last gnome to arrive opened the door ((use monitors and operations on monitors) allowing everyone to get in. Once they entered the cabin, they were mesmerized by how beautiful and clean their house looked. They could immediately see the TV-remote, which was a miracle. It didn’t take them too long to find Sky-blue. The gnomes then started to make a lot of noise trying to wake up the princess (notify). Next, they all waited for the princess to let them know how she got there and who she was.

Time for dinner came and the gnomes got very hungry. While Sky_Blue was setting up the table, the gnomes gathered in groups of table_size (use one different monitor for each group). Sky_Blue will signal the group’s members to have a seat and eat. Each member of the group will eat (sleep of random time) and the last gnome of the group (you might use a counter accessed in a mutual exclusion way) to leave the table will let (signal) Sky-Blue know. She then will allow the next group to eat (keep in mind that the last table might not be completely occupied).

Once the dinner ends, the gnomes want to watch a movie (use wait). All the gnomes should be done eating by the time Sky-blue announce the movie. After washing the dishes, Sky-Blue announces the first movie. The movie runs twice. There are only one recliner and a love seat, so only three gnomes can watch the movie at a given time. If a gnome couldn’t get a seat, he will wait for the second run of the movie, and then try to get a seat. Sky-blue is a great time keeper. After sleeping for a fixed amount of time, she will let the gnomes who watched the movie and the ones that are waiting for watching a movie know that the movie has ended (using notifyAll).

Once the recliner and sofa are occupied again, the next movie will start. Sky-Blue, since she is very tired, will sleep during this movie too and after a fixed amount of time she will wake up and announce the end of the second movie.
Once a gnome has watched a movie, or maybe didn’t have the chance to do so, he will go to bed (wait for Sky-Blue to wake him up in the morning).
Sky-Blue will sleep too (sleep of fixed amount of time) and when she wakes up she will wake all of them up again.

In the morning, the gnomes brush their teeth, take a shower and line up for Sky-Blue. In exchange for a diamond, she gives them a kiss and their lunch box (each gnome blocks on a different object and is kissed by Sky-Blue in an FCFS order, a similar implementation to the one in rwcv.java).

Once all the gnomes leave for work you can have all the threads exit.

Program Screenshot:



Program Video:




Get Project Solution Now

Comments