質問編集履歴
6
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
```ここに言語を入力
|
8
8
|
|
9
|
-
String name = "インスタンス名"
|
9
|
+
String name = "インスタンス名"//ここで標準入力したい。
|
10
10
|
|
11
11
|
```
|
12
12
|
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,14 @@
|
|
7
7
|
```ここに言語を入力
|
8
8
|
|
9
9
|
String name = "インスタンス名"
|
10
|
+
|
11
|
+
```
|
12
|
+
|
13
|
+
こうして、squareのgeArea()にアクセスしようと
|
14
|
+
|
15
|
+
```ここに言語を入力
|
16
|
+
|
17
|
+
double area = name.getArea();
|
10
18
|
|
11
19
|
```
|
12
20
|
|
3
必要な部分に削りました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,261 +47,3 @@
|
|
47
47
|
}
|
48
48
|
|
49
49
|
```
|
50
|
-
|
51
|
-
以下はクラスです。
|
52
|
-
|
53
|
-
```ここに言語を入力
|
54
|
-
|
55
|
-
class Shape {
|
56
|
-
|
57
|
-
private String name;
|
58
|
-
|
59
|
-
public Shape(String name) {
|
60
|
-
|
61
|
-
this.name = name;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
public Shape() {
|
66
|
-
|
67
|
-
name = "no name";
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
public String getName() {
|
72
|
-
|
73
|
-
return name;
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
public String toString() {
|
78
|
-
|
79
|
-
return getClass().getName() + " " + name;
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
```
|
86
|
-
|
87
|
-
```ここに言語を入力
|
88
|
-
|
89
|
-
class Circle extends Shape{
|
90
|
-
|
91
|
-
double radius;
|
92
|
-
|
93
|
-
double area, perimater;
|
94
|
-
|
95
|
-
String name;
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Circle(String name ,double radius){
|
100
|
-
|
101
|
-
super(name);
|
102
|
-
|
103
|
-
this.name = name;
|
104
|
-
|
105
|
-
this.radius = radius;
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
double getPerimater(){
|
112
|
-
|
113
|
-
perimater = 2 * Math.PI * radius;
|
114
|
-
|
115
|
-
return perimater;
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
double getArea(){
|
122
|
-
|
123
|
-
area = Math.PI * Math.pow(radius,2);
|
124
|
-
|
125
|
-
return area;
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
public String toString() {
|
132
|
-
|
133
|
-
return getClass().getName() + " " + name;
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
```
|
140
|
-
|
141
|
-
```ここに言語を入力
|
142
|
-
|
143
|
-
class Rectangle extends Shape{
|
144
|
-
|
145
|
-
double width, height;
|
146
|
-
|
147
|
-
double perimater, area;
|
148
|
-
|
149
|
-
String name;
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
Rectangle(String name, double width, double height){
|
154
|
-
|
155
|
-
super(name);
|
156
|
-
|
157
|
-
this.name = name;
|
158
|
-
|
159
|
-
this.width = width;
|
160
|
-
|
161
|
-
this.height = height;
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
double getPerimater(){
|
168
|
-
|
169
|
-
perimater = (width+height) * 2;
|
170
|
-
|
171
|
-
return perimater;
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
double getArea(){
|
178
|
-
|
179
|
-
area = width * height;
|
180
|
-
|
181
|
-
return area;
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
public String toString() {
|
188
|
-
|
189
|
-
return getClass().getName() + " " + name;
|
190
|
-
|
191
|
-
}
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
```
|
196
|
-
|
197
|
-
```ここに言語を入力
|
198
|
-
|
199
|
-
class Square extends Rectangle{
|
200
|
-
|
201
|
-
double side;
|
202
|
-
|
203
|
-
double perimater, area;
|
204
|
-
|
205
|
-
String name;
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
Square(String name, double side){
|
210
|
-
|
211
|
-
super(name,side,side);
|
212
|
-
|
213
|
-
this.name = name;
|
214
|
-
|
215
|
-
this.side = side;
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
public String toString() {
|
222
|
-
|
223
|
-
return getClass().getName() + " " + name;
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
```
|
230
|
-
|
231
|
-
```ここに言語を入力
|
232
|
-
|
233
|
-
class Rhombus extends Square{
|
234
|
-
|
235
|
-
double side, diagonal;
|
236
|
-
|
237
|
-
double perimater, area;
|
238
|
-
|
239
|
-
String name;
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
Rhombus(String name, double side, double diagonal){
|
244
|
-
|
245
|
-
super(name,side);
|
246
|
-
|
247
|
-
this.name = name;
|
248
|
-
|
249
|
-
this.side = side;
|
250
|
-
|
251
|
-
this.diagonal = diagonal;
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
public String toString() {
|
258
|
-
|
259
|
-
return getClass().getName() + " " + name;
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
```
|
268
|
-
|
269
|
-
```ここに言語を入力
|
270
|
-
|
271
|
-
class Parallelogram extends Rectangle{
|
272
|
-
|
273
|
-
double width, height, diagonal;
|
274
|
-
|
275
|
-
double perimater, area;
|
276
|
-
|
277
|
-
String name;
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
Parallelogram(String name, double width, double height, double diagonal){
|
282
|
-
|
283
|
-
super(name,width,height);
|
284
|
-
|
285
|
-
this.name = name;
|
286
|
-
|
287
|
-
this.width = width;
|
288
|
-
|
289
|
-
this.height = height;
|
290
|
-
|
291
|
-
this.diagonal = diagonal;
|
292
|
-
|
293
|
-
}
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
public String toString() {
|
298
|
-
|
299
|
-
return getClass().getName() + " " + name;
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
```
|
306
|
-
|
307
|
-
長くてすみません。
|
2
コード表示の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,7 +82,9 @@
|
|
82
82
|
|
83
83
|
}
|
84
84
|
|
85
|
-
|
85
|
+
```
|
86
|
+
|
87
|
+
```ここに言語を入力
|
86
88
|
|
87
89
|
class Circle extends Shape{
|
88
90
|
|
@@ -134,7 +136,9 @@
|
|
134
136
|
|
135
137
|
}
|
136
138
|
|
137
|
-
|
139
|
+
```
|
140
|
+
|
141
|
+
```ここに言語を入力
|
138
142
|
|
139
143
|
class Rectangle extends Shape{
|
140
144
|
|
@@ -188,7 +192,9 @@
|
|
188
192
|
|
189
193
|
}
|
190
194
|
|
191
|
-
|
195
|
+
```
|
196
|
+
|
197
|
+
```ここに言語を入力
|
192
198
|
|
193
199
|
class Square extends Rectangle{
|
194
200
|
|
@@ -220,7 +226,9 @@
|
|
220
226
|
|
221
227
|
}
|
222
228
|
|
223
|
-
|
229
|
+
```
|
230
|
+
|
231
|
+
```ここに言語を入力
|
224
232
|
|
225
233
|
class Rhombus extends Square{
|
226
234
|
|
@@ -256,6 +264,10 @@
|
|
256
264
|
|
257
265
|
|
258
266
|
|
267
|
+
```
|
268
|
+
|
269
|
+
```ここに言語を入力
|
270
|
+
|
259
271
|
class Parallelogram extends Rectangle{
|
260
272
|
|
261
273
|
double width, height, diagonal;
|
1
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
任意のクラスのインスタンス名
|
1
|
+
任意のクラスのインスタンス名を標準入力したい。
|
test
CHANGED
File without changes
|