16
16
import java .util .logging .Level ;
17
17
import java .util .logging .Logger ;
18
18
19
+ /**
20
+ * The CLI view
21
+ */
19
22
public class ViewCLI extends LocalView implements Runnable {
23
+ /**
24
+ * Logger
25
+ */
20
26
private static final Logger LOG = Logger .getLogger (ViewCLI .class .getName ());
21
-
27
+ /**
28
+ * Standings line
29
+ */
22
30
private static final String STANDINGS_LINE = "{0}) {1} ({2} punti)" ;
23
-
31
+ /**
32
+ * Scanner
33
+ */
24
34
private Scanner scanner ;
35
+ /**
36
+ * Model
37
+ */
25
38
private MiniModel model ;
26
39
40
+ /**
41
+ * Constructor
42
+ */
27
43
public ViewCLI () {
28
44
scanner = new Scanner (System .in );
29
45
}
30
46
47
+ /**
48
+ * Run the CLI
49
+ */
31
50
@ Override
32
51
public synchronized void run () {
33
52
String connection ;
@@ -72,6 +91,14 @@ public synchronized void run() {
72
91
println (Dialogs .getDialog (Dialog .WAIT_MATCH_START ));
73
92
}
74
93
94
+ /**
95
+ * Select object
96
+ * @param objUuid List of the UUID of the objects.
97
+ * @param min Minimum objects.
98
+ * @param max Maximum of objects.
99
+ * @param dialog The dialog type
100
+ * @return List of selected objects
101
+ */
75
102
@ Override
76
103
public synchronized ArrayList <String > selectObject (ArrayList <String > objUuid , int min , int max , Dialog dialog ) {
77
104
// Print options
@@ -118,11 +145,19 @@ public synchronized ArrayList<String> selectObject(ArrayList<String> objUuid, in
118
145
return new ArrayList <>(selectedUuid );
119
146
}
120
147
148
+ /**
149
+ * Show message
150
+ * @param message Massage to be shown.
151
+ */
121
152
@ Override
122
153
public synchronized void showMessage (String message ) {
123
154
println (message );
124
155
}
125
156
157
+ /**
158
+ * Update the model
159
+ * @param model Updated model.
160
+ */
126
161
@ Override
127
162
public synchronized void updateModel (MiniModel model ) {
128
163
// Save new model
@@ -138,6 +173,10 @@ public synchronized void updateModel(MiniModel model) {
138
173
}
139
174
}
140
175
176
+ /**
177
+ * Notify the end of the match
178
+ * @param standings Final Standings of the game.
179
+ */
141
180
@ Override
142
181
public synchronized void notifyEndMatch (ArrayList <StandingsItem > standings ) {
143
182
cls ();
@@ -152,10 +191,18 @@ public synchronized void notifyEndMatch(ArrayList<StandingsItem> standings) {
152
191
}
153
192
}
154
193
194
+ /**
195
+ * Read a line
196
+ * @return The next line to read
197
+ */
155
198
private synchronized String readLine () {
156
199
return scanner .nextLine ();
157
200
}
158
201
202
+ /**
203
+ * Read int
204
+ * @return read an integer value
205
+ */
159
206
private synchronized int readInt () {
160
207
int integer = 0 ;
161
208
boolean valid = false ;
@@ -174,22 +221,40 @@ private synchronized int readInt() {
174
221
return integer ;
175
222
}
176
223
224
+ /**
225
+ * Clear the screen
226
+ */
177
227
private synchronized void cls () {
178
228
println (ColorCLI .ANSI_CLS );
179
229
}
180
230
231
+ /**
232
+ * Print dialog
233
+ * @param dialog The dialog
234
+ * @param params The parameter to fill the dialog
235
+ */
181
236
private synchronized void printDialog (Dialog dialog , String ...params ) {
182
237
println (Dialogs .getDialog (dialog , params ));
183
238
}
184
239
240
+ /**
241
+ * Print a string and go to the next line
242
+ * @param s the string to print
243
+ */
185
244
private synchronized void println (String s ) {
186
245
System .out .println (s );
187
246
}
188
247
248
+ /**
249
+ * Print no string and go to the next line
250
+ */
189
251
private void println () {
190
252
println ("" );
191
253
}
192
254
255
+ /**
256
+ * Disconnect
257
+ */
193
258
@ Override
194
259
public void disconnect () {
195
260
super .disconnect ();
0 commit comments