diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5ccc446 --- /dev/null +++ b/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da88288 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.gradle/ diff --git a/.project b/.project new file mode 100644 index 0000000..a3e06b8 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + MapPush2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/src/Latitude.java b/src/Latitude.java new file mode 100644 index 0000000..d9f9f3b --- /dev/null +++ b/src/Latitude.java @@ -0,0 +1,16 @@ +import java.util.*; + +public class Latitude { + private MapLatitude mapLatitude; + private double value; + public Latitude(MapLatitude mapLatitude) { + this.mapLatitude = mapLatitude; + } + public double getValue() { + return this.value; + } + public void updateGPS(double lat2, double long2) { + this.value = lat2; + this.mapLatitude.updateLatitude(this.value); + } +} \ No newline at end of file diff --git a/src/Longitude.java b/src/Longitude.java new file mode 100644 index 0000000..b533c8a --- /dev/null +++ b/src/Longitude.java @@ -0,0 +1,16 @@ +import java.util.*; + +public class Longitude { + private MapLongitude mapLongitude; + private double value; + public Longitude(MapLongitude mapLongitude) { + this.mapLongitude = mapLongitude; + } + public double getValue() { + return this.value; + } + public void updateGPS(double lat2, double long2) { + this.value = long2; + this.mapLongitude.updateLongitude(this.value); + } +} \ No newline at end of file diff --git a/src/Map.java b/src/Map.java new file mode 100644 index 0000000..abfd465 --- /dev/null +++ b/src/Map.java @@ -0,0 +1,30 @@ +import java.util.*; + +public class Map { + private MapLongitude mapLongitude; + private Longitude longitude; + private MapLatitude mapLatitude; + private Latitude latitude; + public Map() { + this.mapLongitude = new MapLongitude(); + this.longitude = new Longitude(mapLongitude); + this.mapLatitude = new MapLatitude(); + this.latitude = new Latitude(mapLatitude); + } + public double getMapLongitude() { + return mapLongitude.getValue(); + } + public double getLongitude() { + return longitude.getValue(); + } + public void updateGPS(double lat2, double long2) { + this.longitude.updateGPS(lat2, long2); + this.latitude.updateGPS(lat2, long2); + } + public double getMapLatitude() { + return mapLatitude.getValue(); + } + public double getLatitude() { + return latitude.getValue(); + } +} \ No newline at end of file diff --git a/src/MapLatitude.java b/src/MapLatitude.java new file mode 100644 index 0000000..a6d2448 --- /dev/null +++ b/src/MapLatitude.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class MapLatitude { + private double value; + public double getValue() { + return this.value; + } + public void updateLatitude(double latitude) { + this.value = latitude; + } +} \ No newline at end of file diff --git a/src/MapLongitude.java b/src/MapLongitude.java new file mode 100644 index 0000000..8ce23f5 --- /dev/null +++ b/src/MapLongitude.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class MapLongitude { + private double value; + public double getValue() { + return this.value; + } + public void updateLongitude(double longitude) { + this.value = longitude; + } +} \ No newline at end of file diff --git a/src/TestGPSUpdate.java b/src/TestGPSUpdate.java new file mode 100644 index 0000000..dde1480 --- /dev/null +++ b/src/TestGPSUpdate.java @@ -0,0 +1,46 @@ + + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class TestGPSUpdate { + + @Test + public void test() { + // �k��35.0�x�C���o135.0�x�ɐݒ肷�� + Map map = new Map(); + map.updateGPS(35.0, 135.0); + double lati = map.getLatitude(); + double longi = map.getLongitude(); + double mapLati = map.getMapLatitude(); + double mapLongi = map.getMapLongitude(); + assertEquals(lati, 35.0, 0.0001); + assertEquals(longi, 135.0, 0.0001); + assertEquals(mapLati, 35.0, 0.0001); + assertEquals(mapLongi, 135.0, 0.0001); + + // �ܓx�����Ɉړ����� + map.updateGPS(35.1, 135.0); + lati = map.getLatitude(); + longi = map.getLongitude(); + mapLati = map.getMapLatitude(); + mapLongi = map.getMapLongitude(); + assertEquals(lati, 35.1, 0.0001); + assertEquals(longi, 135.0, 0.0001); + assertEquals(mapLati, 35.1, 0.0001); + assertEquals(mapLongi, 135.0, 0.0001); + + // �o�x�����Ɉړ����� + map.updateGPS(35.1, 135.1); + lati = map.getLatitude(); + longi = map.getLongitude(); + mapLati = map.getMapLatitude(); + mapLongi = map.getMapLongitude(); + assertEquals(lati, 35.1, 0.0001); + assertEquals(longi, 135.1, 0.0001); + assertEquals(mapLati, 35.1, 0.0001); + assertEquals(mapLongi, 135.1, 0.0001); + } + +}