ouais
This commit is contained in:
parent
8839c351b9
commit
de8f816d66
3 changed files with 34 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
||||||
*.class
|
*.class
|
||||||
*.jar
|
*.jar
|
||||||
saves/*.yaml
|
saves/*.txt
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
|
||||||
public class AppLaser {
|
public class AppLaser {
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
|
@ -63,7 +65,9 @@ public class AppLaser {
|
||||||
System.out.println("\n1 - Resize universe");
|
System.out.println("\n1 - Resize universe");
|
||||||
System.out.println("2 - Change start position");
|
System.out.println("2 - Change start position");
|
||||||
System.out.println("3 - Add obstacle");
|
System.out.println("3 - Add obstacle");
|
||||||
System.out.println("4 - Resolve");
|
System.out.println("4 - Save universe");
|
||||||
|
System.out.println("5 - Load universe");
|
||||||
|
System.out.println("6 - Resolve");
|
||||||
System.out.println("0 - Exit");
|
System.out.println("0 - Exit");
|
||||||
|
|
||||||
// prompt the user
|
// prompt the user
|
||||||
|
@ -126,6 +130,33 @@ public class AppLaser {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
System.out.print("\nHow do you want to name your universe : ");
|
||||||
|
String name = "";
|
||||||
|
|
||||||
|
while (name.isEmpty()) {
|
||||||
|
name = scanner.nextLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
File file = new File("./saves/" + name + ".txt");
|
||||||
|
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
FileWriter writer = new FileWriter("./saves/" + name + ".txt");
|
||||||
|
|
||||||
|
for (int i = 0; i < universe_height + 2; i++) {
|
||||||
|
for (int j = 0; j < universe_width + 2; j++) {
|
||||||
|
writer.write(universe.grid[i][j]);
|
||||||
|
}
|
||||||
|
writer.write("\n");
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
catch (Exception e) {}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
boolean display_progress = false, display_regress = false;
|
boolean display_progress = false, display_regress = false;
|
||||||
|
|
||||||
System.out.println("\n1 - display progress and regress");
|
System.out.println("\n1 - display progress and regress");
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
public class Universe {
|
public class Universe {
|
||||||
// Atributes
|
// Atributes
|
||||||
|
|
||||||
private int[][] grid;
|
public int[][] grid;
|
||||||
private int width, height;
|
private int width, height;
|
||||||
private int boxes_to_fill;
|
private int boxes_to_fill;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue