java - receiving a Specific value from other class which is not connected -


i have create checkers board game , have 4 classes:

  1. cell(for representing empty cell returns tostring ".")
  2. white(represents white cell , returns tostring "w")
  3. black(represents black cell , returns tostring "b")
  4. checkers(which sets board(cell[8][8]) , initializes it.

i having problem calling in empty, white , black cells represented letters .,w,b. have more work on code need in calling methods

the cell, black , white classes looks these:

  public class cell {  public static final string empty=".";   int i;  int j;  string value;   public cell(int i, int j){     this.i = i;     this.j = j;     value = empty;  }   public string tostring(){     return value;  } } 

and in checkers class have these methods: dont know how call other classes created char array , put values in. know have work more on this.

    /*********initialization******/ public void init(){     board = new cell[8][8];       char[][] =         {             getemptywhite("ew"),             getemptywhite("we"),             getemptywhite("ew"),             getemptywhite("ee"),             getemptywhite("ee"),             getemptywhite("be"),             getemptywhite("eb"),             getemptywhite("be")          };     for(int = 0; i<8; i++){         for(int j=0; j<8; j++){             system.out.print(a[i][j]);         }         system.out.println();     } }       public char[] getemptywhite(string a){         cell empty;         black black;         white white;             if(a.equals(empty)){             char[] emptywhite = {'e','e','e','e','e','e','e','e'};             return emptywhite;         }         else if(a.equals("ew")){             char[] emptywhite = {'e','w','e','w','e','w','e','w'};              return emptywhite;         }         else if(a.equals("eb")){             char[] emptywhite = {'e','b','e','b','e','b','e','b'};             return emptywhite;         } else if(a.equals("we")){             char[] emptywhite = {'w','e','w','e','w','e','w','e'};             return emptywhite;                   } else if(a.equals("be")){             char[] emptywhite = {'b','e','b','e','b','e','b','e'};             return emptywhite;                   }          return null;     }    /*********initialization ended*******/ 

inside getemptywhite, looks instead of line:

if(a.equals(empty)){ 

you should using this:

if(a.equals("ee")){ 

note in code posted, empty variable of type cell value of null. thus, a.equals(empty) false. also, don't need local variables empty, black, , white.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -