質問編集履歴
2
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
.
|
body
CHANGED
@@ -1,62 +1,1 @@
|
|
1
|
-
Circle
|
2
|
-
|
3
|
-
###前提・実現したいこと
|
4
|
-
メソッドscaleを利用して,内部でCircleのスケールを呼び出し,内側の円と,外側の円のratio倍の円を作り,それらを用いて,新しいドーナツ型を作成して返したい.
|
5
|
-
|
6
|
-
###発生している問題・エラーメッセージ
|
7
|
-
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - bad operand types for binary operator '*'
|
8
|
-
first type: double
|
9
|
-
second type: Donut
|
10
|
-
|
11
|
-
###該当のソースコード
|
12
|
-
public class Donut {
|
13
|
-
|
14
|
-
Circle inner;
|
15
|
-
Circle outer;
|
16
|
-
|
17
|
-
Donut(Circle inner, Circle outer) {
|
18
|
-
this.inner = inner;
|
19
|
-
this.outer = outer;
|
20
|
-
}
|
21
|
-
|
22
|
-
double getArea() {
|
23
|
-
return this.outer.getArea() - this.inner.getArea();
|
24
|
-
}
|
25
|
-
|
26
|
-
Donut scale(double ratio) {
|
27
|
-
this.inner.scale(ratio);
|
28
|
-
this.outer.scale(ratio);
|
29
|
-
|
1
|
+
.............................................. .
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
public class Circle {
|
36
|
-
|
37
|
-
double r;
|
38
|
-
|
39
|
-
Circle(double r) {
|
40
|
-
this.r = r;
|
41
|
-
}
|
42
|
-
|
43
|
-
double getArea() {
|
44
|
-
return this.r * this.r * Math.PI;
|
45
|
-
}
|
46
|
-
|
47
|
-
Circle scale(double ratio) {
|
48
|
-
this.r *= ratio;
|
49
|
-
return new Circle(this.r * this.r * Math.PI);
|
50
|
-
}
|
51
|
-
|
52
|
-
boolean isIdetical(Circle circle2) {
|
53
|
-
return this.r == circle2.r;
|
54
|
-
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
###補足情報(言語/FW/ツール等のバージョンなど)
|
62
|
-
開発環境 Netbeans 8.1
|
1
Circleクラスを追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,6 +32,31 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
public class Circle {
|
35
36
|
|
37
|
+
double r;
|
38
|
+
|
39
|
+
Circle(double r) {
|
40
|
+
this.r = r;
|
41
|
+
}
|
42
|
+
|
43
|
+
double getArea() {
|
44
|
+
return this.r * this.r * Math.PI;
|
45
|
+
}
|
46
|
+
|
47
|
+
Circle scale(double ratio) {
|
48
|
+
this.r *= ratio;
|
49
|
+
return new Circle(this.r * this.r * Math.PI);
|
50
|
+
}
|
51
|
+
|
52
|
+
boolean isIdetical(Circle circle2) {
|
53
|
+
return this.r == circle2.r;
|
54
|
+
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
36
61
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
37
62
|
開発環境 Netbeans 8.1
|