Deleted and modified previous sprint parser to cater the sprint2’s new requirement

- also added new method for GateMark

#story[9] #story[10] #fix
This commit is contained in:
Haoming Yin
2017-03-17 00:53:08 +13:00
parent b7631c0b46
commit e7ba9d962d
4 changed files with 40 additions and 21 deletions
+20 -1
View File
@@ -8,13 +8,32 @@ public class GateMark {
private double lon;
private Mark mark1;
private Mark mark2;
public Mark getMark1() {
return mark1;
}
public Mark getMark2() {
return mark2;
}
public String getName() {
return name;
}
private String name;
public GateMark(String name, Mark mark1, Mark mark2, double lat, double lon){
public GateMark(String name, Mark mark1, Mark mark2, double lat, double lon) {
this.lat = lat;
this.lon = lon;
this.mark1 = mark1;
this.mark2 = mark2;
this.name = name;
}
public GateMark(String name, Mark mark1, Mark mark2) {
this.mark1 = mark1;
this.mark2 = mark2;
this.name = name;
}
}
+2 -2
View File
@@ -16,11 +16,11 @@ public class OldApp {
*/
public static Race createRace(String configFile) throws Exception {
Race race = new Race();
FileParser fp;
OldFileParser fp;
// Read team names from file
try{
fp = new FileParser(configFile);
fp = new OldFileParser(configFile);
}
catch (FileNotFoundException e){
System.out.println("Config file does not exist");
@@ -16,7 +16,7 @@ import java.util.Map;
* efficiently from external files.
*/
public class FileParser {
public class OldFileParser {
private String filePath;
private JSONObject content;
@@ -27,7 +27,7 @@ public class FileParser {
* @param filePath a string like path to show location of desired file to
* be parsed
*/
public FileParser(String filePath) throws Exception {
public OldFileParser(String filePath) throws Exception {
this.filePath = filePath;
this.readFile();
}
@@ -1,7 +1,7 @@
package seng302;
import org.junit.Test;
import seng302.models.FileParser;
import seng302.models.OldFileParser;
import java.io.FileNotFoundException;
@@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals;
* Unit test for FileParser class
* Created by Haoming on 5/03/17.
*/
public class FileParserTest {
public class OldFileParserTest {
/**
* test if it fails from reading non existed file
*/
@Test(expected = FileNotFoundException.class)
public void readNonExistedFile() throws Exception {
FileParser fileParser = new FileParser("test/java/seng302/non-existed.json");
OldFileParser fileParser = new OldFileParser("test/java/seng302/non-existed.json");
}
/**
@@ -26,7 +26,7 @@ public class FileParserTest {
*/
@Test
public void readValidFile() throws Exception {
FileParser fileParser = new FileParser("src/test/java/seng302/valid.json");
OldFileParser fileParser = new OldFileParser("src/test/java/seng302/valid.json");
assertEquals("AC35", fileParser.getRaceName());
@@ -42,7 +42,7 @@ public class FileParserTest {
*/
@Test
public void readInvalidFile() throws Exception {
FileParser fileParser = new FileParser("src/test/java/seng302/invalid.json");
OldFileParser fileParser = new OldFileParser("src/test/java/seng302/invalid.json");
assertEquals(null, fileParser.getRaceName());
assertEquals(null, fileParser.getTeams());