





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






A stack is a linear data structure that can only be accessed at one of its ends for storage and retrieve data. Such a stack is like a stack of trays in the cafeteria: the new trays are put on the top of the stack and take out top. The last tray put on the stack is the first tray removed from the stack. Hence, it is called the Last in First out (LIFO) or First in Last out (FILO) list. Thus, Stack is used to store the process messages. A queue is simply a queue that grows by adding element at the end and shrinking by talking elements from it front. Unlike a stack, a queue is a structure in which both ends are used: one to add new elements and one for removing them. So, the last element has to wait until all elements preceding it on the queue are deleted. Hence, it is called First in First out (FIFO) or Last on Last out (LILO) list. Thus, Queue is used to store the transported messages. The message will be added to the queue, if the queue is full then the message will not be added to the queue.
1.1 Flowchart Figure 1. Main program chart 1.2 Design the ADT and algorithm To solve this problem, I have designed Stack and Queue ADT for handing the requirements as below: First, I have designed a “Message” object to store the messages in the system.
Figure 3. The “MyStack” class Then, I will design the queue ADT for the system.
Figure 4. The “Queue” class Finally, I will create a "Main" class for the system with the following functions: