mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
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:
@@ -4,17 +4,36 @@ package seng302.models;
|
||||
* Created by ptg19 on 16/03/17.
|
||||
*/
|
||||
public class GateMark {
|
||||
private double lat;
|
||||
private double lon;
|
||||
private Mark mark1;
|
||||
private Mark mark2;
|
||||
private String name;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private Mark mark1;
|
||||
private Mark mark2;
|
||||
|
||||
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 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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
+2
-2
@@ -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();
|
||||
}
|
||||
+5
-5
@@ -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());
|
||||
Reference in New Issue
Block a user