Add example network files and update interactive console commands for improved usability
This commit is contained in:
@@ -39,12 +39,11 @@ public class InteractiveConsole {
|
||||
/**
|
||||
* Run the interactive net builder.
|
||||
*/
|
||||
public Net runNetBuilder() {
|
||||
public Net run() {
|
||||
while (true) {
|
||||
try {
|
||||
var choice = choose("Choose the next step to do:",
|
||||
"Add a node", "Add a connection", "Print Nodes", "Save the net", "Load net", "Clear",
|
||||
"Exit");
|
||||
var choice = choose(this.net + "\nChoose the next step to do:",
|
||||
"Add a node", "Add a connection", "Save the net", "Load net", "Clear", "Exit");
|
||||
switch (choice) {
|
||||
case 1 -> {
|
||||
var node = this.buildNode();
|
||||
@@ -58,8 +57,9 @@ public class InteractiveConsole {
|
||||
var targetNode = this.net.getNode(target);
|
||||
this.net.addConnection(sourceNode, targetNode, weight);
|
||||
}
|
||||
case 3 -> this.out.println(this.net);
|
||||
case 4 -> this.net.save(ask("Enter the filename: "));
|
||||
case 3 -> this.net.save(ask("Enter the filename: "));
|
||||
case 4 -> this.net = Net.load(ask("Enter the filename: "));
|
||||
case 5 -> this.net = new Net();
|
||||
default -> {
|
||||
this.scanner.close();
|
||||
return this.net;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Main {
|
||||
var plot = new Plot(csv);
|
||||
plot.show();
|
||||
}
|
||||
case "net" -> new InteractiveConsole().runNetBuilder();
|
||||
case "interactive" -> new InteractiveConsole().run();
|
||||
default -> exit("Invalid program!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -83,11 +83,11 @@ public class Main {
|
||||
var uri = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI();
|
||||
var name = new File(uri).getName();
|
||||
System.err.println(message);
|
||||
System.out.println("Usage: java -jar " + name + ".jar [simulation|plot|net] [args]");
|
||||
System.out.println("Usage: java -jar " + name + ".jar [simulation|plot|interactive] [args]");
|
||||
System.out.println("simulation args: -net <net> [-csv <csv>] [-runs <runs>] [-seed <seed>]"
|
||||
+ "[-p] [-end <end>] [-i <indices>]");
|
||||
System.out.println("plot args: -csv <csv>");
|
||||
System.out.println("net args: none");
|
||||
System.out.println("interactive: no args needed");
|
||||
System.exit(1);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user