Add javadoc to client package (no subpackage)
This commit is contained in:
parent
4062f43c40
commit
94cd0bb030
@ -50,6 +50,17 @@ public class App extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse players arguments and create a new instance of Game
|
||||
* @throws IllegalArgumentException when given argument is unknown
|
||||
* @throws InvocationTargetException when the creation of the player throw an exception
|
||||
* @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])}
|
||||
* doesn't exist
|
||||
* @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract),
|
||||
* is probably never called
|
||||
* @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor),
|
||||
* is probably never called
|
||||
*/
|
||||
public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
|
||||
InstantiationException, IllegalAccessException {
|
||||
List<Player> players = parsePlayers();
|
||||
@ -80,6 +91,17 @@ public class App extends Application {
|
||||
viewManager.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse players arguments and create instances for each player
|
||||
* @throws IllegalArgumentException when given argument is unknown
|
||||
* @throws InvocationTargetException when the creation of the player throw an exception
|
||||
* @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])}
|
||||
* doesn't exist
|
||||
* @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract),
|
||||
* is probably never called
|
||||
* @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor),
|
||||
* is probably never called
|
||||
*/
|
||||
public static List<Player> parsePlayers() throws IllegalArgumentException, NoSuchMethodException,
|
||||
InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
List<Player> playerList = new ArrayList<>();
|
||||
@ -129,6 +151,17 @@ public class App extends Application {
|
||||
return playerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new instance of the player
|
||||
* @throws IllegalArgumentException when given argument is unknown (probably never called in production)
|
||||
* @throws InvocationTargetException when the creation of the player throw an exception
|
||||
* @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])}
|
||||
* doesn't exist
|
||||
* @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract),
|
||||
* is probably never called
|
||||
* @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor),
|
||||
* is probably never called
|
||||
*/
|
||||
private static Player createNewPlayer(Class<? extends AbstractPlayer> playerClass, ClassPlayer playerType,
|
||||
int playerListSize) throws NoSuchMethodException, InvocationTargetException,
|
||||
InstantiationException, IllegalAccessException {
|
||||
@ -136,7 +169,12 @@ public class App extends Application {
|
||||
.newInstance(playerListSize, null, playerType);
|
||||
}
|
||||
|
||||
public static Class<? extends AbstractView> parseView() {
|
||||
/**
|
||||
* Parse the first argument given by user to know the view to use (Terminal or Window)
|
||||
* @return The class of the View to use
|
||||
* @throws IllegalArgumentException when given argument is unknown or no argument is given by user
|
||||
*/
|
||||
public static Class<? extends AbstractView> parseView() throws IllegalArgumentException {
|
||||
Class<? extends AbstractView> clazz;
|
||||
if(!argsList.isEmpty()) {
|
||||
if(argsList.get(0).equals("terminal")) {
|
||||
|
@ -3,6 +3,9 @@ package fr.lnl.game.client;
|
||||
import fr.lnl.game.client.view.View;
|
||||
import fr.lnl.game.server.games.player.Player;
|
||||
|
||||
/**
|
||||
* Store a view per player
|
||||
*/
|
||||
public record ClientPlayer(Player serverPlayer, View view) {
|
||||
|
||||
public Player getServerPlayer() {
|
||||
|
@ -3,9 +3,17 @@ package fr.lnl.game.client;
|
||||
import fr.lnl.game.client.view.View;
|
||||
import fr.lnl.game.server.games.player.Player;
|
||||
|
||||
/**
|
||||
* Used as Lambda expression to instantiate a {@link View} per {@link Player} stored in {@link ClientPlayer}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ViewLambda {
|
||||
|
||||
/**
|
||||
* A lambda create an anonymous class which implements this interface
|
||||
* @param player an instance of {@link Player} to store in {@link View}
|
||||
* @return an instance of view (depending on the first argument when launching the program)
|
||||
*/
|
||||
View createViewLambda(Player player);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Client package
|
||||
*/
|
||||
package fr.lnl.game.client;
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Server package
|
||||
*/
|
||||
package fr.lnl.game.server;
|
Loading…
Reference in New Issue
Block a user