diff --git a/src/A.java b/src/A.java new file mode 100644 index 0000000..736f3ae --- /dev/null +++ b/src/A.java @@ -0,0 +1,17 @@ +public class A { + private C c; + private double value; + public A(C c) { + this.c = c; + } + public void updateValue(double lat) { + this.value = lat; + } + public double getValue() { + return this.value; + } + public void updateGPS(double lat2, double long2) { + this.value = lat2; + this.c.updateLatitude(this.value); + } +} \ No newline at end of file diff --git a/src/B.java b/src/B.java new file mode 100644 index 0000000..e0cd592 --- /dev/null +++ b/src/B.java @@ -0,0 +1,17 @@ +public class B { + private D d; + private double value; + public B(D d) { + this.d = d; + } + public void updateValue(double lng) { + this.value = lng; + } + public double getValue() { + return this.value; + } + public void updateGPS(double lat2, double long2) { + this.value = long2; + this.d.updateLongitude(this.value); + } +} \ No newline at end of file diff --git a/src/C.java b/src/C.java new file mode 100644 index 0000000..4583623 --- /dev/null +++ b/src/C.java @@ -0,0 +1,9 @@ +public class C { + 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/D.java b/src/D.java new file mode 100644 index 0000000..2f83e7e --- /dev/null +++ b/src/D.java @@ -0,0 +1,9 @@ +public class D { + 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/Map.java b/src/Map.java index abfd465..acbfb34 100644 --- a/src/Map.java +++ b/src/Map.java @@ -1,30 +1,71 @@ -import java.util.*; - public class Map { - private MapLongitude mapLongitude; - private Longitude longitude; - private MapLatitude mapLatitude; - private Latitude latitude; + private D d; + private B b; + private C c; + private A a; + private Presenter presenter; public Map() { - this.mapLongitude = new MapLongitude(); - this.longitude = new Longitude(mapLongitude); - this.mapLatitude = new MapLatitude(); - this.latitude = new Latitude(mapLatitude); + this.d = new D(); + this.b = new B(d); + this.c = new C(); + this.a = new A(c); + this.presenter = new Presenter(this.a, this.b, this.c, this.d); } +// public Map(A a, B b, C c, D d) { +// this.presenter = new Presenter(a, b, c, d); +// } public double getMapLongitude() { - return mapLongitude.getValue(); + return d.getValue(); } public double getLongitude() { - return longitude.getValue(); + return b.getValue(); } public void updateGPS(double lat2, double long2) { - this.longitude.updateGPS(lat2, long2); - this.latitude.updateGPS(lat2, long2); - } + this.presenter.updateGPS(lat2, long2); + } public double getMapLatitude() { - return mapLatitude.getValue(); + return c.getValue(); } public double getLatitude() { - return latitude.getValue(); + return a.getValue(); } -} \ No newline at end of file + public void setAutoUpdateEnabled(boolean enabled) { + this.presenter.setAutoUpdateEnabled(enabled); + } + + public void manualUpdate() { + this.presenter.manualUpdate(); + } +} + + +//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/Presenter.java b/src/Presenter.java new file mode 100644 index 0000000..7a986b0 --- /dev/null +++ b/src/Presenter.java @@ -0,0 +1,40 @@ +public class Presenter { + private A a; + private B b; + private C c; + private D d; + private boolean autoUpdateEnabled = true; // �f�t�H���g�Ŏ����X�V��ON + + public Presenter(A a, B b, C c, D d) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + } + + public void updateGPS(double lat, double lng) { + // A��B�̏�Ԃ��X�V���� + a.updateValue(lat); // A�����ˆܓx�����X�V + b.updateValue(lng); // B�����Œo�x�����X�V + + // �����X�V��ON�̏ꍇ�̂݁A�n�}�̒��S�ʒu���X�V���� + if (autoUpdateEnabled) { + c.updateLatitude(lat); // �n�}�̒��S�ʒu�̈ܓx���X�V + d.updateLongitude(lng); // �n�}�̒��S�ʒu�̌o�x���X�V + } + } + + // �����X�V��ON/OFF��؂�ւ��郁�\�b�h + public void setAutoUpdateEnabled(boolean enabled) { + this.autoUpdateEnabled = enabled; + } + + // �蓮�X�V�{�^���������ꂽ���ɒn�}�̒��S�ʒu���X�V���郁�\�b�h + public void manualUpdate() { + if (!autoUpdateEnabled) { + // �����X�V��OFF�̏ꍇ�A�蓮�Œn�}�̒��S�ʒu���X�V���� + c.updateLatitude(a.getValue()); + d.updateLongitude(b.getValue()); + } + } +} \ No newline at end of file