Add launch arguments

This commit is contained in:
Quentin Legot 2023-03-10 08:06:56 +01:00
parent 60c2e5c69b
commit f9cea33e9f
3 changed files with 22 additions and 17 deletions

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

View File

@ -10,7 +10,10 @@ plugins {
id 'application' id 'application'
} }
run {
args = ["5000", "20"]
}
application { application {
mainClassName = 'fr.ntr.Main' mainClassName = 'fr.ntr.Main'
} }

View File

@ -1,22 +1,36 @@
package fr.ntr; package fr.ntr;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
/** /**
* nombre de ticks de la simulation * Nombre de ticks de la simulation
* -> durée de la simulation * -> durée de la simulation
*/ */
int numberOfTicks = 5000; int numberOfTicks = 5000;
/** /**
* nombre maximal d'utilisateurs dans le système * Nombre maximal d'utilisateurs dans le système
*/ */
int maximumLoad = 20; int maximumLoad = 20;
//TODO ajouter accès à AccessPoint //TODO ajouter accès à AccessPoint
System.out.println("Hello World"); if(args.length == 2) {
try {
numberOfTicks = Integer.parseInt(args[0]);
maximumLoad = Integer.parseInt(args[1]);
System.out.println("ticks: " + numberOfTicks + ", users: " + maximumLoad);
} catch (NumberFormatException e) {
System.err.println("Cannot parse launch argument to integer");
System.exit(1);
}
} else {
System.err.println("Please give launch arguments");
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
System.exit(1);
}
} }
} }