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

回答編集履歴

3

訂正3

2016/11/14 10:59

投稿

退会済みユーザー
answer CHANGED
@@ -43,10 +43,10 @@
43
43
  TOP = 0, SOUTH = 1, EAST = 2,
44
44
  WEST = 3, NORTH = 4, BOTTOM = 5; // 定数
45
45
 
46
- public Dice(Object obj){ // コンストラクタ
46
+ public Dice(Object ...obj){ // コンストラクタ
47
47
  for(int i = 0; i < 6; i++){
48
- if(obj instanceof int[]){
48
+ if(obj[0] instanceof int[]){
49
- int[] d = (int[]) obj;
49
+ int[] d = (int[]) obj[0];
50
50
  _d[i] = d[i];
51
51
  }
52
52
  }

2

訂正2

2016/11/14 10:59

投稿

退会済みユーザー
answer CHANGED
@@ -11,7 +11,7 @@
11
11
  public static void main(String[] args){
12
12
 
13
13
  int n = scan.nextInt();
14
- Integer[] d = new Integer[6];
14
+ int[] d = new int[6];
15
15
  Dice[] dices = new Dice[n];
16
16
 
17
17
 
@@ -19,8 +19,8 @@
19
19
  for(int j = 0; j < 6; j++){
20
20
  d[j] = scan.nextInt();
21
21
  }
22
- Object[] objs = (Object[]) d;
22
+ Object objs = d;
23
- dices[i] = new Dice((Object[]) objs);
23
+ dices[i] = new Dice((Object) objs);
24
24
  }
25
25
 
26
26
  boolean ans = true;
@@ -43,14 +43,10 @@
43
43
  TOP = 0, SOUTH = 1, EAST = 2,
44
44
  WEST = 3, NORTH = 4, BOTTOM = 5; // 定数
45
45
 
46
- public Dice(Object... obj){ // コンストラクタ
46
+ public Dice(Object obj){ // コンストラクタ
47
- Integer c[]=new Integer[6];
48
47
  for(int i = 0; i < 6; i++){
49
-
50
- System.out.println(obj.getClass());
51
- if(obj instanceof Integer[]){
48
+ if(obj instanceof int[]){
52
-
53
- Integer[] d = (Integer[])obj;
49
+ int[] d = (int[]) obj;
54
50
  _d[i] = d[i];
55
51
  }
56
52
  }

1

訂正

2016/11/14 10:55

投稿

退会済みユーザー
answer CHANGED
@@ -49,7 +49,7 @@
49
49
 
50
50
  System.out.println(obj.getClass());
51
51
  if(obj instanceof Integer[]){
52
- System.out.println("qwe");
52
+
53
53
  Integer[] d = (Integer[])obj;
54
54
  _d[i] = d[i];
55
55
  }