diff --git a/app/src/main/java/school_project/Parsers/FileParser.java b/app/src/main/java/school_project/Parsers/FileParser.java index f1c7015..20182bf 100644 --- a/app/src/main/java/school_project/Parsers/FileParser.java +++ b/app/src/main/java/school_project/Parsers/FileParser.java @@ -3,7 +3,6 @@ package school_project.Parsers; import school_project.Map; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; public interface FileParser { @@ -24,5 +23,5 @@ public interface FileParser { * @param file the file where to save * @param levelData the map to save */ - void saveLevel(File file, Map levelData, boolean save_data) throws FileNotFoundException; + void saveLevel(File file, Map levelData, boolean save_data) throws IOException; } diff --git a/app/src/main/java/school_project/Parsers/JsonParser.java b/app/src/main/java/school_project/Parsers/JsonParser.java index 0e15404..12b350f 100644 --- a/app/src/main/java/school_project/Parsers/JsonParser.java +++ b/app/src/main/java/school_project/Parsers/JsonParser.java @@ -8,17 +8,7 @@ import java.nio.file.Files; public class JsonParser implements FileParser{ @Override - public Map getSavedData(File file) { - return null; - } - - @Override - public void saveLevel(File file, Map levelData) throws FileNotFoundException { - - } - - @Override - public void saveLevelData(File file, Map levelData) throws IOException { + public void saveLevel(File file, Map levelData, boolean save_data) throws IOException { FileOutputStream fileStream = new FileOutputStream(file); ObjectOutputStream objectStream = new ObjectOutputStream(fileStream); objectStream.writeObject(levelData); @@ -36,7 +26,7 @@ public class JsonParser implements FileParser{ } @Override - public Map getLevel(File file) throws IOException { + public Map getLevel(File file, boolean saved_data) throws IOException { FileInputStream fileStream = new FileInputStream(file); ObjectInputStream objectStream = new ObjectInputStream(fileStream); try { diff --git a/app/src/test/java/school_project/Parsers/JsonParserTest.java b/app/src/test/java/school_project/Parsers/JsonParserTest.java index 08f2185..8273a0d 100644 --- a/app/src/test/java/school_project/Parsers/JsonParserTest.java +++ b/app/src/test/java/school_project/Parsers/JsonParserTest.java @@ -24,10 +24,10 @@ class JsonParserTest { map.addPiece(new Piece(piece1)); map.addPiece(new Piece(piece2)); JsonParser parser = new JsonParser(); - parser.saveLevelData(new File("test.json"), map); + parser.saveLevel(new File("test.json"), map, false); FileParser p2 = FileParserFactory.createParser(new File("test.json")); - Map map2 = p2.getLevel(new File("test.json")); + Map map2 = p2.getLevel(new File("test.json"), false); assertArrayEquals(map2.getShape(), map.getShape()); assertArrayEquals(map2.getUsedSpace(), map.getUsedSpace()); }