質問編集履歴
1
足りない部分を追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
private int number;
|
3
3
|
private int[] x = new int[number];
|
4
4
|
private int[] y = new int[number];
|
5
|
+
private int a = 10;
|
6
|
+
private int b = 30;
|
5
7
|
|
6
|
-
public Test() {
|
8
|
+
public Test(String name) {
|
7
9
|
|
8
10
|
switch(name) {
|
9
11
|
case "first":
|
@@ -15,7 +17,21 @@
|
|
15
17
|
for(int i = 1; i < number; i++) {
|
16
18
|
this.y[i] = this[i-1] + b;
|
17
19
|
}
|
20
|
+
break;
|
21
|
+
case "second":
|
22
|
+
this.number = 8;
|
23
|
+
for(int i = 0; i < number; i++) {
|
24
|
+
this.x[i] = a * 2;
|
25
|
+
}
|
26
|
+
this.y[0] = b * 3;
|
27
|
+
for(int i = 1; i < number; i++) {
|
28
|
+
this.y[i] = this[i-1] + b * 3;
|
29
|
+
}
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
}
|
18
33
|
|
34
|
+
|
19
35
|
xとyの初期値を決めようとすると、xのfor文の中で、
|
20
36
|
ArrayIndexOutOfBoundsException
|
21
37
|
エラーが出ます。
|