質問するログイン新規登録

質問編集履歴

1

Point.javaとPointObj.javaを追記しました。忘れていました、申し訳ありません。

2019/07/13 04:47

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -138,6 +138,52 @@
138
138
 
139
139
  ```
140
140
 
141
+ ### Point.java
141
142
 
143
+ ```java
144
+ public interface Point {
145
+ public double getX();
146
+ public double getY();
147
+ public double dist(Point q);
148
+ }
149
+
150
+ ```
151
+
152
+ ### PointObj.java
153
+
154
+ ```java
155
+ public class PointObj implements Point {
156
+
157
+ double x;
158
+ double y;
159
+
160
+ PointObj(double x, double y) {
161
+ this.x = x;
162
+ this.y = y;
163
+ }
164
+
165
+ public double getX() {
166
+ return this.x;
167
+ }
168
+
169
+ public double getY() {
170
+ return this.y;
171
+ }
172
+
173
+ public double dist(Point q) {
174
+ double dx = this.x - q.getX();
175
+ double dy = this.y - q.getY();
176
+ return Math.sqrt(dx*dx + dy*dy);
177
+ }
178
+
179
+ public String toString() {
180
+ return "(" + this.x + ", " + this.y + ")";
181
+ }
182
+
183
+ }
184
+
185
+ ```
186
+
187
+
142
188
  ### 試したこと
143
189
  メソッド名等、誤字脱字がないか何度も確認しました。