diff --git a/src/A.java b/src/A.java index 4f7e82a..736f3ae 100644 --- a/src/A.java +++ b/src/A.java @@ -4,6 +4,9 @@ public A(C c) { this.c = c; } + public void updateValue(double lat) { + this.value = lat; + } public double getValue() { return this.value; } diff --git a/src/B.java b/src/B.java index 30ec773..e0cd592 100644 --- a/src/B.java +++ b/src/B.java @@ -4,6 +4,9 @@ public B(D d) { this.d = d; } + public void updateValue(double lng) { + this.value = lng; + } public double getValue() { return this.value; } diff --git a/src/Map.java b/src/Map.java index f7017c1..a58f444 100644 --- a/src/Map.java +++ b/src/Map.java @@ -3,12 +3,16 @@ private B b; private C c; private A a; + private Presenter presenter; public Map() { this.d = new D(); this.b = new B(d); this.c = new C(); this.a = new A(c); } + public Map(A a, B b, C c, D d) { + this.presenter = new Presenter(a, b, c, d); + } public double getMapLongitude() { return d.getValue(); } @@ -16,15 +20,21 @@ return b.getValue(); } public void updateGPS(double lat2, double long2) { - this.b.updateGPS(lat2, long2); - this.a.updateGPS(lat2, long2); - } + this.presenter.updateGPS(lat2, long2); + } public double getMapLatitude() { return c.getValue(); } public double getLatitude() { return a.getValue(); } + public void setAutoUpdateEnabled(boolean enabled) { + this.presenter.setAutoUpdateEnabled(enabled); + } + + public void manualUpdate() { + this.presenter.manualUpdate(); + } } 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