Add launch arguments
This commit is contained in:
parent
60c2e5c69b
commit
f9cea33e9f
12
.classpath
12
.classpath
@ -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>
|
@ -10,7 +10,10 @@ plugins {
|
||||
id 'application'
|
||||
}
|
||||
|
||||
run {
|
||||
args = ["5000", "20"]
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'fr.ntr.Main'
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,36 @@
|
||||
package fr.ntr;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
/**
|
||||
* nombre de ticks de la simulation
|
||||
* Nombre de ticks de la simulation
|
||||
* -> durée de la simulation
|
||||
*/
|
||||
int numberOfTicks = 5000;
|
||||
|
||||
/**
|
||||
* nombre maximal d'utilisateurs dans le système
|
||||
* Nombre maximal d'utilisateurs dans le système
|
||||
*/
|
||||
int maximumLoad = 20;
|
||||
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user