-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplayHandler.java
More file actions
40 lines (38 loc) · 1.17 KB
/
DisplayHandler.java
File metadata and controls
40 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import javax.swing.JOptionPane;
/**
*This class defines two overloaded constructors,
*in order to match the overloaded constructors in "GeneralHandler" class
*/
public class DisplayHandler extends GeneralHandler{
/**DisplayHandler constructor, initializes a new DisplayHandler
*@param intQ the reference to a Queue of Integers
*/
public DisplayHandler(Queue<Integer> intQ){
super(intQ);
}
/**DisplayHandler constructor, initializes a new DisplayHandler
*@param intSt the reference to a Stack of Integers
*/
public DisplayHandler(Stack<Integer> intSt){
super(intSt);
}
@Override
/**This method implements the abstract method "processRequest",
*inherited from GeneralHandler class. This method displays the contents
*of the Queue/Stack respectively and presents a message to the user
*/
public void processRequest(){
JOptionPane dialog = new JOptionPane();
String action=null,type=null;
if(intQ==null){
action="push";
type="Stack";
dialog.showMessageDialog(null,type+" contents is: "+intSt );
}
else {
action="enqueue";
type="Queue";
dialog.showMessageDialog(null,type+" contents is: "+intQ );
}
}
}