質問編集履歴
2
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
.
|
test
CHANGED
@@ -1,123 +1 @@
|
|
1
|
-
Circle
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
###前提・実現したいこと
|
6
|
-
|
7
|
-
メソッドscaleを利用して,内部でCircleのスケールを呼び出し,内側の円と,外側の円のratio倍の円を作り,それらを用いて,新しいドーナツ型を作成して返したい.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
###発生している問題・エラーメッセージ
|
12
|
-
|
13
|
-
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - bad operand types for binary operator '*'
|
14
|
-
|
15
|
-
first type: double
|
16
|
-
|
17
|
-
second type: Donut
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
###該当のソースコード
|
22
|
-
|
23
|
-
public class Donut {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
Circle inner;
|
28
|
-
|
29
|
-
Circle outer;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
Donut(Circle inner, Circle outer) {
|
34
|
-
|
35
|
-
this.inner = inner;
|
36
|
-
|
37
|
-
this.outer = outer;
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
double getArea() {
|
44
|
-
|
45
|
-
return this.outer.getArea() - this.inner.getArea();
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Donut scale(double ratio) {
|
52
|
-
|
53
|
-
this.inner.scale(ratio);
|
54
|
-
|
55
|
-
this.outer.scale(ratio);
|
56
|
-
|
57
|
-
|
1
|
+
.............................................. .
|
58
|
-
|
59
|
-
}
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
public class Circle {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
double r;
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
Circle(double r) {
|
78
|
-
|
79
|
-
this.r = r;
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
double getArea() {
|
86
|
-
|
87
|
-
return this.r * this.r * Math.PI;
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
Circle scale(double ratio) {
|
94
|
-
|
95
|
-
this.r *= ratio;
|
96
|
-
|
97
|
-
return new Circle(this.r * this.r * Math.PI);
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
boolean isIdetical(Circle circle2) {
|
104
|
-
|
105
|
-
return this.r == circle2.r;
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
###補足情報(言語/FW/ツール等のバージョンなど)
|
122
|
-
|
123
|
-
開発環境 Netbeans 8.1
|
1
Circleクラスを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,6 +66,56 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
+
public class Circle {
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
double r;
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
Circle(double r) {
|
78
|
+
|
79
|
+
this.r = r;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
double getArea() {
|
86
|
+
|
87
|
+
return this.r * this.r * Math.PI;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Circle scale(double ratio) {
|
94
|
+
|
95
|
+
this.r *= ratio;
|
96
|
+
|
97
|
+
return new Circle(this.r * this.r * Math.PI);
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
boolean isIdetical(Circle circle2) {
|
104
|
+
|
105
|
+
return this.r == circle2.r;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
69
119
|
|
70
120
|
|
71
121
|
###補足情報(言語/FW/ツール等のバージョンなど)
|