Skip to content
Snippets Groups Projects
Commit 22c6d84d authored by Håvard Daleng's avatar Håvard Daleng
Browse files

Improved CLI-app to add super basic user input handling.

parent 48c09af2
No related branches found
No related tags found
No related merge requests found
......@@ -8,17 +8,21 @@ import edu.ntnu.stud.chaosgame.model.handling.ChaosCanvas;
import edu.ntnu.stud.chaosgame.model.handling.ChaosGame;
import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D;
import edu.ntnu.stud.chaosgame.model.transformations.Transform2D;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
/**
* Main class for the Chaos Game application.
*/
public class Main {
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.println("Hi");
String path = "src/main/resources/descriptions/Sierpinski.txt";
String path = "src/main/resources/descriptions/sierpinski.txt";
ChaosGameDescription description = null; // Declare description
......@@ -34,7 +38,34 @@ public class Main {
} catch (Exception e) {
System.out.println(e.getMessage()); // TODO: Alter error handling
}
game.runSteps(100000);
boolean exit = false;
// While loop for simple cli-app.
while (!exit) {
System.out.println("What would you like to do? Type 1 for displaying fractal, "
+ "or anything else for ending the program");
if (Objects.equals(sc.next(), "1")) {
game.runSteps(100000);
System.out.println(
"What would you like to do? Type 1 for saving the fractal, anything else for ending the program");
if (Objects.equals(sc.next(), "1")) {
ChaosGameFileHandler handler = new ChaosGameFileHandler();
handler.writeToFile(description, "src/main/resources/descriptions/output.txt");
System.out.println("Wrote to file output.txt.");
}
else {
exit = true;
}
}
else {
exit = true;
}
}
System.out.println("Terminated program.");
......
Affine2D
0.0, 0.0
1.0, 1.0
0.5, 0.0, 0.0, 0.5, 0.0, 0.0
0.5, 0.0, 0.0, 0.5, 0.25, 0.5
0.5, 0.0, 0.0, 0.5, 0.5, 0.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment