こんにちは、学校の課題で重力3目並べを作っていますが、式の型、int型、配列型というところでまったくつまずいてしまっています。どうか課題提出できますようお助けいただけますでしょうか。お願いいたします。私はJUNO eclipsをつかっております。 エラーは、34,50,53,66,118行目で”式の型は配列方でINTに解決済みである必要があります”です。 (申し訳ありません。文字数ぎりぎりで詰めて質問させていただきした。読みづらですがご容赦ください。 package Colonne5; public class Colonne5 { final static int jouer1 = 0; final static int jouer2 = 1; final static char [] pion = new char [] {'*','0', ' '}; final static int vide = 2; static final int PionEtoile = 1; static final int PionRond = -1; final static int Dwidth = 5; final static int Dheight = 5; final static int PreCOL = 0; final static int DerCOL = Dwidth - 1; final static int Hautligne = Dheight - 1; static int Basligne = 0; final static int H = 0 ; final static int V = 1 ; final static int[] HOR = new int[] {1, 0} ; final static int[] VER = new int[] {0, 1} ; final static int[] UP = new int[] {1, 1} ; final static int[] DOWN = new int[] {1, -1} ; final static int[][] DIRECTION = new int[][] {HOR, VER, UP, DOWN} ; private static int[][] damier ; // grid private static int name ; // player name private static char player ; // turn of gamer private static int result ; private static int impactLine ; public Colonne5 (int john){ damier = new int[Dwidth][Dheight]; for (int i = 0 ; i < Dwidth; i++) { for (int j = 0; j < Dheight; j++) { damier[i][j] = vide; } } this.name = john; player = jouer1; result = vide; } private boolean Libre(int column){ //グリッドが空いているか判断 return damier[column][Hautligne]==vide; } private boolean damierRempli() { int column = PreCOL; while (column <= DerCOL) { if (Libre(column)) return true ; column++ ; } return false ; } private void jouerCoup() throws IOException { //ゲーム開始 while (result == vide && damierRempli()) { afficher() ; int column =name[player]; System.out.print("Enter " + (PreCOL + 1) + " to " +(DerCOL +1) + " ?") ; System.in.read(); sommetColonne(column) ; if (coupGagnant(player, impactLine)) result = player ; else demanderCoup() ; } afficher() ; if (result == vide) System.out.print(" partie nulle ") ; else System.out.println(name[result] + " gagne") ; } private boolean coupGagnant (int column, int ligne) { //勝者判断 int i = 0 ; while (i < DIRECTION.length) { if (coupGagnant(column, ligne, DIRECTION[i])) return true ; i++ ; } return false ; } private static boolean coupGagnant(int column, int ligne ,int[] dir) { int nextColumn = column + dir[H] ; int nextLine = ligne + dir[V] ; int forward = 0 ; while (damier[nextColumn][nextLine] == player) { nextColumn += dir[H] ; nextLine += dir[V] ; forward++ ; } nextColumn = column - dir[H] ; nextLine = ligne - dir[V] ; int backward = 0 ; while (damier[nextColumn][nextLine] == player) { nextColumn -= dir[H] ; nextLine -= dir[V] ; backward++ ; } return backward + 1 + forward >= 3 ; } private static int demanderCoup() { //どちらのプレイヤーの順番か判断 if(player==jouer1){ player = jouer2; } else player = jouer1; return player; } private void sommetColonne(int column) { //現在の駒の一番上を取得判断 if(!Libre(impactLine)) throw new RuntimeException(" colonne pleine ") ; impactLine = Hautligne ; while (impactLine > Basligne && damier[Dheight-1][impactLine-1] == vide) impactLine-- ; damier[Basligne][impactLine] = player ; } private void afficher() { //ゲームの表示 for (int column = PreCOL ; column <= DerCOL ; column++) System.out.print("| " + (column + 1) + " "); System.out.println("|"); for (int line = Hautligne ; line >= Basligne ; line--) { for (int column = PreCOL ; column <= DerCOL ; column++) System.out.print("| " + pion[damier[column][line]] + " ") ; System.out.println("|"); } } public static void main(String[] args) { Colonne5 joue = new Colonne5(name) ; joue.jouerCoup(); } }
↧