mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added an attribute to each yacht: 'DistanceToNextMark'
This attribute is calculated at each update of the boat as prompted by the game state regularly Removed the lat and lng attribute from the Yacht class and replaced its usage with the GeoPoint object instead Removed redundant test files and merged GeoUtility and testGeoUtil test classes into one tags: #story[1124] #pair[hyi25, wmu16]
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package seng302.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
|
||||
/**
|
||||
* Use this link to test geo distances
|
||||
* http://www.csgnetwork.com/gpsdistcalc.html
|
||||
* Created by wmu16 on 3/08/17.
|
||||
*/
|
||||
public class YachtTest {
|
||||
|
||||
private Yacht yacht;
|
||||
private CompoundMark compoundMark;
|
||||
private Double toleranceRatio = 0.01;
|
||||
private GeoPoint p1 = new GeoPoint(57.670333, 11.827833);
|
||||
private GeoPoint p2 = new GeoPoint(57.671524, 11.844495);
|
||||
private GeoPoint p3 = new GeoPoint(57.670822, 11.843392);
|
||||
private GeoPoint p4 = new GeoPoint(25.694829, 98.392049);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
yacht = new Yacht("Yacht",
|
||||
0,
|
||||
"0",
|
||||
"WillIsCool",
|
||||
"HaomingIsOk",
|
||||
"NZL");
|
||||
|
||||
yacht.setLat(57.670333);
|
||||
yacht.setLon(11.827833);
|
||||
|
||||
compoundMark = new CompoundMark(0, "HaomingsMark");
|
||||
Mark subMark1 = new Mark("H", 57.671524, 11.844495, 0);
|
||||
Mark subMark2 = new Mark("H", 57.670822, 11.843392, 0);
|
||||
compoundMark.addSubMarks(subMark1, subMark2);
|
||||
|
||||
yacht.setNextMark(compoundMark);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDistanceToNextMark() {
|
||||
Double actual, expected;
|
||||
actual = yacht.calcDistanceToNextMark();
|
||||
expected = 927d;
|
||||
assertEquals(expected, actual, expected * toleranceRatio);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
//package seng302.model.mark;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//import static org.junit.Assert.assertTrue;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
///**
|
||||
// * Created by Haoming on 17/3/17.
|
||||
// */
|
||||
//public class MarkTest {
|
||||
//
|
||||
// private SingleMark singleMark1;
|
||||
// private SingleMark singleMark2;
|
||||
// private GateMark gateMark;
|
||||
//
|
||||
// @Before
|
||||
// public void setUp() throws Exception {
|
||||
// this.singleMark1 = new SingleMark("testMark_SM1", 12.23234, -34.342, 1, 0);
|
||||
// this.singleMark2 = new SingleMark("testMark_SM2", 12.23239, -34.352, 2, 1);
|
||||
// this.gateMark = new GateMark("testMark_GM", MarkType.OPEN_GATE, singleMark1, singleMark2, singleMark1.getLatitude(), singleMark2.getLongitude(), 2);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void getName() throws Exception {
|
||||
// assertEquals("testMark_SM1", this.singleMark1.getName());
|
||||
// assertEquals("testMark_GM", this.gateMark.getName());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void getMarkType() throws Exception {
|
||||
// assertTrue(this.singleMark2.getMarkType() == MarkType.SINGLE_MARK);
|
||||
// assertTrue(this.gateMark.getMarkType() == MarkType.OPEN_GATE);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void getMarkContent() throws Exception {
|
||||
// assertEquals(12.23234, this.singleMark1.getLatitude(), 1e-10);
|
||||
// assertEquals(-34.342, this.singleMark1.getLongitude(), 1e-10);
|
||||
// assertEquals("testMark_SM1", this.gateMark.getSingleMark1().getName());
|
||||
// assertEquals(-34.352, this.gateMark.getSingleMark2().getLongitude(), 1e-10);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
Reference in New Issue
Block a user