small correction
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Debucquoy 2023-03-23 15:24:59 +01:00
parent ad301ca7fb
commit 194de024ff
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
3 changed files with 5 additions and 16 deletions

View File

@ -3,7 +3,6 @@ package school_project.Parsers;
import school_project.Map; import school_project.Map;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
public interface FileParser { public interface FileParser {
@ -24,5 +23,5 @@ public interface FileParser {
* @param file the file where to save * @param file the file where to save
* @param levelData the map 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;
} }

View File

@ -8,17 +8,7 @@ import java.nio.file.Files;
public class JsonParser implements FileParser{ public class JsonParser implements FileParser{
@Override @Override
public Map getSavedData(File file) { public void saveLevel(File file, Map levelData, boolean save_data) throws IOException {
return null;
}
@Override
public void saveLevel(File file, Map levelData) throws FileNotFoundException {
}
@Override
public void saveLevelData(File file, Map levelData) throws IOException {
FileOutputStream fileStream = new FileOutputStream(file); FileOutputStream fileStream = new FileOutputStream(file);
ObjectOutputStream objectStream = new ObjectOutputStream(fileStream); ObjectOutputStream objectStream = new ObjectOutputStream(fileStream);
objectStream.writeObject(levelData); objectStream.writeObject(levelData);
@ -36,7 +26,7 @@ public class JsonParser implements FileParser{
} }
@Override @Override
public Map getLevel(File file) throws IOException { public Map getLevel(File file, boolean saved_data) throws IOException {
FileInputStream fileStream = new FileInputStream(file); FileInputStream fileStream = new FileInputStream(file);
ObjectInputStream objectStream = new ObjectInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(fileStream);
try { try {

View File

@ -24,10 +24,10 @@ class JsonParserTest {
map.addPiece(new Piece(piece1)); map.addPiece(new Piece(piece1));
map.addPiece(new Piece(piece2)); map.addPiece(new Piece(piece2));
JsonParser parser = new JsonParser(); 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")); 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.getShape(), map.getShape());
assertArrayEquals(map2.getUsedSpace(), map.getUsedSpace()); assertArrayEquals(map2.getUsedSpace(), map.getUsedSpace());
} }