-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientGetOrQuitState.java
72 lines (59 loc) · 1.55 KB
/
ClientGetOrQuitState.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
public class ClientGetOrQuitState extends MessageState
{
/*
Amber Krause
December 6, 2016
CISC 230-02
Doctor Jarvis
This class models the ClientGetOrQuitState dialog box.
Class variables:
instance
the ClientGetOrQuitState object.
Enumeration types:
StateName
represents the buttons in the dialog box.
Constructors:
ClientGetOrQuitState()
creates a new ClientGetOrQuitState object.
Methods:
getInstance()
accessor for instance.
execute()
launches the dialog box and returns the next NavigationState.
Modification History:
December 6, 2016
original version.
*/
private enum StateName
{
GetAFile,
Quit;
} //enum StateName
private static ClientGetOrQuitState instance = new ClientGetOrQuitState();
private ClientGetOrQuitState()
{
super(StateName.values());
} //constructor
public static ClientGetOrQuitState getInstance()
{
return ClientGetOrQuitState.instance;
} //getInstance
public NavigationState execute()
{
//launches the dialog box and return the next NavigationState
StateName buttonClicked;
NavigationState nextState;
buttonClicked = StateName.valueOf(super.showDialog());
switch(buttonClicked)
{
case GetAFile:
{
nextState = ClientSelectFileState.getInstance();
break;
} //case GetAFile
case Quit: { nextState = null; break; }
default: { throw new IllegalArgumentException("ClientGetOrQuitState.execute: no execution statement has been written for this case"); }
} //switch
return nextState;
} //execute
} //class ClientGetOrQuitStateState