Skip to content

Commit 903a5ad

Browse files
committed
Add comments for JavaDoc
1 parent d6ade25 commit 903a5ad

19 files changed

+602
-23
lines changed

src/main/java/it/polimi/ingsw/view/cli/ViewCLI.java

+67-2
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,37 @@
1616
import java.util.logging.Level;
1717
import java.util.logging.Logger;
1818

19+
/**
20+
* The CLI view
21+
*/
1922
public class ViewCLI extends LocalView implements Runnable {
23+
/**
24+
* Logger
25+
*/
2026
private static final Logger LOG = Logger.getLogger(ViewCLI.class.getName());
21-
27+
/**
28+
* Standings line
29+
*/
2230
private static final String STANDINGS_LINE = "{0}) {1} ({2} punti)";
23-
31+
/**
32+
* Scanner
33+
*/
2434
private Scanner scanner;
35+
/**
36+
* Model
37+
*/
2538
private MiniModel model;
2639

40+
/**
41+
* Constructor
42+
*/
2743
public ViewCLI() {
2844
scanner = new Scanner(System.in);
2945
}
3046

47+
/**
48+
* Run the CLI
49+
*/
3150
@Override
3251
public synchronized void run() {
3352
String connection;
@@ -72,6 +91,14 @@ public synchronized void run() {
7291
println(Dialogs.getDialog(Dialog.WAIT_MATCH_START));
7392
}
7493

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+
*/
75102
@Override
76103
public synchronized ArrayList<String> selectObject(ArrayList<String> objUuid, int min, int max, Dialog dialog) {
77104
// Print options
@@ -118,11 +145,19 @@ public synchronized ArrayList<String> selectObject(ArrayList<String> objUuid, in
118145
return new ArrayList<>(selectedUuid);
119146
}
120147

148+
/**
149+
* Show message
150+
* @param message Massage to be shown.
151+
*/
121152
@Override
122153
public synchronized void showMessage(String message) {
123154
println(message);
124155
}
125156

157+
/**
158+
* Update the model
159+
* @param model Updated model.
160+
*/
126161
@Override
127162
public synchronized void updateModel(MiniModel model) {
128163
// Save new model
@@ -138,6 +173,10 @@ public synchronized void updateModel(MiniModel model) {
138173
}
139174
}
140175

176+
/**
177+
* Notify the end of the match
178+
* @param standings Final Standings of the game.
179+
*/
141180
@Override
142181
public synchronized void notifyEndMatch(ArrayList<StandingsItem> standings) {
143182
cls();
@@ -152,10 +191,18 @@ public synchronized void notifyEndMatch(ArrayList<StandingsItem> standings) {
152191
}
153192
}
154193

194+
/**
195+
* Read a line
196+
* @return The next line to read
197+
*/
155198
private synchronized String readLine() {
156199
return scanner.nextLine();
157200
}
158201

202+
/**
203+
* Read int
204+
* @return read an integer value
205+
*/
159206
private synchronized int readInt() {
160207
int integer = 0;
161208
boolean valid = false;
@@ -174,22 +221,40 @@ private synchronized int readInt() {
174221
return integer;
175222
}
176223

224+
/**
225+
* Clear the screen
226+
*/
177227
private synchronized void cls() {
178228
println(ColorCLI.ANSI_CLS);
179229
}
180230

231+
/**
232+
* Print dialog
233+
* @param dialog The dialog
234+
* @param params The parameter to fill the dialog
235+
*/
181236
private synchronized void printDialog(Dialog dialog, String ...params) {
182237
println(Dialogs.getDialog(dialog, params));
183238
}
184239

240+
/**
241+
* Print a string and go to the next line
242+
* @param s the string to print
243+
*/
185244
private synchronized void println(String s) {
186245
System.out.println(s);
187246
}
188247

248+
/**
249+
* Print no string and go to the next line
250+
*/
189251
private void println() {
190252
println("");
191253
}
192254

255+
/**
256+
* Disconnect
257+
*/
193258
@Override
194259
public void disconnect() {
195260
super.disconnect();

src/main/java/it/polimi/ingsw/view/cli/component/BoardCLI.java

+28-1
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,31 @@
88
import java.util.ArrayList;
99
import java.util.List;
1010

11+
/**
12+
* Represent the board in the CLI
13+
*/
1114
public class BoardCLI {
15+
/**
16+
* Length of the square
17+
*/
1218
public static final int LENGTH = 25;
13-
19+
/**
20+
* Board to represent
21+
*/
1422
private MiniBoard miniBoard;
1523

24+
/**
25+
* Constructor
26+
* @param miniBoard Board to represent
27+
*/
1628
public BoardCLI(MiniBoard miniBoard){
1729
this.miniBoard=miniBoard;
1830
}
1931

32+
/**
33+
* Generate a List of string to represent the board whit character
34+
* @return the list of string
35+
*/
2036
public List<String> viewBoard() {
2137
MiniSquare ms;
2238
List<String> outList = new ArrayList<>();
@@ -63,6 +79,11 @@ public List<String> viewBoard() {
6379
return outList;
6480
}
6581

82+
/**
83+
* Generate the square
84+
* @param ms the square to generate
85+
* @return the list of string that represents the square
86+
*/
6687
public List<String> viewSquare(MiniSquare ms) {
6788
ArrayList<String> outList = new ArrayList<>();
6889
String out ;
@@ -155,6 +176,12 @@ else if (ms.getClass() == MiniStandardSquare.class) {
155176
return outList;
156177
}
157178

179+
/**
180+
* Search a square knowing its coordinate
181+
* @param list List of squares to search in
182+
* @param coordinate Coordinate of the square to search
183+
* @return the square to find
184+
*/
158185
private MiniSquare searchSquare(List<MiniSquare> list, Coordinate coordinate) {
159186
for (MiniSquare ms : list) {
160187
if (coordinate.equals(ms.getCoordinates()))

src/main/java/it/polimi/ingsw/view/cli/component/GameBoardCLI.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,32 @@
99
import java.util.ArrayList;
1010
import java.util.List;
1111

12+
/**
13+
* Represent the game board in the CLI
14+
*/
1215
public class GameBoardCLI {
13-
16+
/**
17+
* The board CLI
18+
*/
1419
private BoardCLI boardCLI;
20+
/**
21+
* The game board to represent
22+
*/
1523
private MiniGameBoard miniGameBoard;
1624

25+
/**
26+
* Constructor
27+
* @param miniGameBoard the game board to represent
28+
*/
1729
public GameBoardCLI(MiniGameBoard miniGameBoard){
1830
this.miniGameBoard = miniGameBoard;
1931
this.boardCLI = new BoardCLI(miniGameBoard.getBoard());
2032
}
2133

34+
/**
35+
* Generate the list of strings that represent the game board
36+
* @return list of strings that represent the game board
37+
*/
2238
public List<String> viewGameBoard(){
2339
ArrayList<String> outLIst = new ArrayList<>();
2440
String out=" ";

src/main/java/it/polimi/ingsw/view/cli/component/MatchCLI.java

+20
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
/**
11+
* Represent the Match in the CLI
12+
*/
1013
public class MatchCLI {
14+
/**
15+
* The game board CLI
16+
*/
1117
private GameBoardCLI gameBoardCLI;
18+
/**
19+
* List of players
20+
*/
1221
private ArrayList<PlayerCLI> playerCLI;
22+
/**
23+
* Match to represent
24+
*/
1325
private MiniMatch miniMatch;
1426

27+
/**
28+
* Constructor
29+
* @param miniMatch match to represent
30+
*/
1531
public MatchCLI(MiniMatch miniMatch) {
1632
this.miniMatch = miniMatch;
1733
this.gameBoardCLI = new GameBoardCLI(miniMatch.getGameBoard());
@@ -21,6 +37,10 @@ public MatchCLI(MiniMatch miniMatch) {
2137
}
2238
}
2339

40+
/**
41+
* Generate the list of strings that represent the match
42+
* @return list of strings that represent the match
43+
*/
2444
public List<String> viewMatch(){
2545
List<String> outList = new ArrayList<>();
2646
List<String> squareList = new ArrayList<>();

src/main/java/it/polimi/ingsw/view/cli/component/ModelCLI.java

+20
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,38 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8+
/**
9+
* Represent the model in the CLI
10+
*/
811
public class ModelCLI {
12+
/**
13+
* Model to represent
14+
*/
915
private MiniModel miniModel;
16+
/**
17+
* Match CLI
18+
*/
1019
private MatchCLI matchCLI;
20+
/**
21+
* Player CLI
22+
*/
1123
private PlayerCLI playerCLI;
1224

25+
/**
26+
* Constructor
27+
* @param miniModel the model to represent
28+
*/
1329
public ModelCLI(MiniModel miniModel) {
1430
this.miniModel = miniModel;
1531
this.playerCLI = new PlayerCLI(miniModel.getMyMiniPlayer(), miniModel.getMyPowerUps());
1632
miniModel.getMatch().getPlayers().remove(miniModel.getMyMiniPlayer());
1733
this.matchCLI = new MatchCLI(miniModel.getMatch());
1834
}
1935

36+
/**
37+
* Generate the list of strings that represent the model
38+
* @return list of strings that represent the model
39+
*/
2040
public List<String> viewModel(){
2141
List<String> outList = new ArrayList<>();
2242
String out;

src/main/java/it/polimi/ingsw/view/cli/component/PlayerCLI.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,32 @@
1111
import java.util.ArrayList;
1212
import java.util.List;
1313

14+
/**
15+
* Represent the player in the CLI
16+
*/
1417
public class PlayerCLI {
15-
18+
/**
19+
* Length of the container
20+
*/
1621
static final int LENGTH = 25;
17-
22+
/**
23+
* Player to represent
24+
*/
1825
private MiniPlayer player;
26+
/**
27+
* List of player's power-ups
28+
*/
1929
private List<MiniPowerUp> powerUp;
30+
/**
31+
* Weapon CLI
32+
*/
2033
private ArrayList<WeaponCLI> weaponCLI;
2134

35+
/**
36+
* Constructor
37+
* @param miniPlayer the player to represent
38+
* @param powerUp the list of player's power-ups
39+
*/
2240
PlayerCLI(MiniPlayer miniPlayer, List<MiniPowerUp> powerUp){
2341
this.player = miniPlayer;
2442
this.powerUp = powerUp;
@@ -28,6 +46,10 @@ public class PlayerCLI {
2846
}
2947
}
3048

49+
/**
50+
* Generate the list of strings that represent the player
51+
* @return list of strings that represent the player
52+
*/
3153
public synchronized List<String> viewPlayer(){
3254
int space;
3355
String out;

src/main/java/it/polimi/ingsw/view/cli/component/WeaponCLI.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@
88
import java.util.ArrayList;
99
import java.util.List;
1010

11+
/**
12+
* Represent the weapon in the CLI
13+
*/
1114
public class WeaponCLI {
15+
/**
16+
* The weapon to represent
17+
*/
1218
private MiniWeapon miniWeapon;
19+
/**
20+
* Length of the space
21+
*/
1322
private static final int LENGTH = 25 ;
1423

24+
/**
25+
* Constructor
26+
* @param miniWeapon the weapon to represent
27+
*/
1528
public WeaponCLI(MiniWeapon miniWeapon) {
1629
this.miniWeapon = miniWeapon;
1730
}
18-
31+
/**
32+
* Generate the list of strings that represent the weapon
33+
* @return list of strings that represent the weapon
34+
*/
1935
public List<String> viewWeapon(){
2036
String out;
2137
int space;

0 commit comments

Comments
 (0)