Hello people.
I have the following class.

public class Model{
      private Kutia[][] c;
   
   
      public Model(Kutia[][] x){
         c = touch(x);
      
      }
   	
      public void touch(Kutia[][] k){
         for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
               if(k[i][j].occupied()){
                  touchHorizontal(k, i, j);
                  touchVertical(k, i, j);						
               }
            }
         }
      }
   
      public void touchHorizontal(Kutia[][] k, int i, int j){
         for(int r = 0; r < 8; r++){
            if(r != j){
               k[r][j].increaseVlera();
            }
         }
      }
   
      public void touchVertical(Kutia[][] k, int i, int j){
         for(int r = 0; r < 8; r++){
            if(r != i){
               k[i][r].increaseVlera();
            }
         }	
      }
   
   
      public Kutia[][] modeled(){
         return c;
      }
   
   }

Compiler is complaining for line six - incompatible types. I don't get it: how is a Kutia[][] object incompatible with another Kutia[][] object. please help.

Recommended Answers

All 3 Replies

Your touch method is a void return

public void touch(Kutia[][] k)

You can't assign that to your 'c' variable.

thank you a lot Ezzaral. kind regards!

I replaced line six with the following two lines, and expect it to work find. (in case some other reader may be interested)

c = x;
	touch(c);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.