diff --git a/src/Map.java b/src/Map.java index 1abf7c6..0ab2c4f 100644 --- a/src/Map.java +++ b/src/Map.java @@ -26,12 +26,19 @@ public double getLatitude() { return latitude.getValue(); } - // �����X�V��ON/OFF���\�b�h�Ǝ蓮�X�V���\�b�h��Map�N���X�ŌĂяo����悤�ɂ��� - public void setAutoUpdateEnabled(boolean enabled) { - presenter.setAutoUpdateEnabled(enabled); +// // �����X�V��ON/OFF���\�b�h�Ǝ蓮�X�V���\�b�h��Map�N���X�ŌĂяo����悤�ɂ��� +// public void setAutoUpdateEnabled(boolean enabled) { +// presenter.setAutoUpdateEnabled(enabled); +// } +// +// public void manualUpdate() { +// presenter.manualUpdate(); +// } + public void setAutoUpdate(boolean autoUpdate) { + presenter.setAutoUpdate(autoUpdate); } - public void manualUpdate() { - presenter.manualUpdate(); + public void updateManually() { + presenter.updateManually(); } } \ No newline at end of file diff --git a/src/Presenter.java b/src/Presenter.java index a65c61d..63571eb 100644 --- a/src/Presenter.java +++ b/src/Presenter.java @@ -1,5 +1,6 @@ public class Presenter { - private boolean autoUpdateEnabled = true; // ������Ԃł͎����X�V��ON�ɂ��܂� +// private boolean autoUpdateEnabled = true; // ������Ԃł͎����X�V��ON�ɂ��܂� + private boolean isAutoUpdate = true; private Longitude longitude; private Latitude latitude; private MapLongitude mapLongitude; @@ -11,27 +12,46 @@ this.mapLongitude = mapLongitude; this.mapLatitude = mapLatitude; } - + public void updateGPS(double lat2, double long2) { - // GPS�̏�Ԃ��X�V���܂� longitude.updateValue(long2); latitude.updateValue(lat2); - // �����X�V���L���ȏꍇ�̂ݒn�}�̒��S�ʒu���X�V���܂� - if (autoUpdateEnabled) { + if (isAutoUpdate) { mapLongitude.updateLongitude(long2); mapLatitude.updateLatitude(lat2); } } - // �����X�V��ON/OFF��؂�ւ��郁�\�b�h - public void setAutoUpdateEnabled(boolean enabled) { - this.autoUpdateEnabled = enabled; + public void setAutoUpdate(boolean autoUpdate) { + this.isAutoUpdate = autoUpdate; } - // �蓮�X�V���s�����\�b�h - public void manualUpdate() { + public void updateManually() { mapLongitude.updateLongitude(longitude.getValue()); mapLatitude.updateLatitude(latitude.getValue()); } + +// public void updateGPS(double lat2, double long2) { +// // GPS�̏�Ԃ��X�V���܂� +// longitude.updateValue(long2); +// latitude.updateValue(lat2); +// +// // �����X�V���L���ȏꍇ�̂ݒn�}�̒��S�ʒu���X�V���܂� +// if (autoUpdateEnabled) { +// mapLongitude.updateLongitude(long2); +// mapLatitude.updateLatitude(lat2); +// } +// } + +// // �����X�V��ON/OFF��؂�ւ��郁�\�b�h +// public void setAutoUpdateEnabled(boolean enabled) { +// this.autoUpdateEnabled = enabled; +// } +// +// // �蓮�X�V���s�����\�b�h +// public void manualUpdate() { +// mapLongitude.updateLongitude(longitude.getValue()); +// mapLatitude.updateLatitude(latitude.getValue()); +// } } \ No newline at end of file diff --git a/src/TestManualUpdate.java b/src/TestManualUpdate.java new file mode 100644 index 0000000..dfb4613 --- /dev/null +++ b/src/TestManualUpdate.java @@ -0,0 +1,69 @@ +import static org.junit.Assert.*; + +import org.junit.Test; + +public class TestManualUpdate { + + @Test + public void test() { + // �k��35.0�x�C���o135.0�x�C�����X�V���[�h�ɐݒ肷�� + Map map = new Map(); + map.updateGPS(35.0, 135.0); + map.setAutoUpdate(true); + 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); + + // �k��35.1�x�C���o135.1�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); + + // �蓮�X�V���s�� + map.updateManually(); + 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); + + // �蓮�X�V���[�h�ɐݒ肷�� + map.setAutoUpdate(false); + + // �k��35.0�x�C���o135.0�x�ɖ߂� + map.updateGPS(35.0, 135.0); + lati = map.getLatitude(); + longi = map.getLongitude(); + mapLati = map.getMapLatitude(); + mapLongi = map.getMapLongitude(); + assertEquals(lati, 35.0, 0.0001); + assertEquals(longi, 135.0, 0.0001); + assertEquals(mapLati, 35.1, 0.0001); // �蓮�X�V�̂��ߒl�͕ω����Ȃ� + assertEquals(mapLongi, 135.1, 0.0001); // �蓮�X�V�̂��ߒl�͕ω����Ȃ� + + // �蓮�X�V���s�� + map.updateManually(); + lati = map.getLatitude(); + longi = map.getLongitude(); + mapLati = map.getMapLatitude(); + mapLongi = map.getMapLongitude(); + assertEquals(lati, 35.0, 0.0001); + assertEquals(longi, 135.0, 0.0001); + assertEquals(mapLati, 35.0, 0.0001); // �蓮�X�V�ɂ���Ēl���X�V����� + assertEquals(mapLongi, 135.0, 0.0001); // �蓮�X�V�ɂ���Ēl���X�V����� + } +} \ No newline at end of file