java - Must explicitly invoke another constructor -


why eclipse keeps giving me error on constructor:

 public denseboard(tile t[][]){       board myboard = new denseboard(t.length, t[0].length);   } 

the error is:implicit super constructor board() undefined. must explicitly invoke constructor

class denseboard

package game2048;  // tracks positions of arbitrary 2d grid of tiles.  denseboard // uses internal, multi-dimensional array store tiles , // has o(r * c) memory footprint (rows columns). public class denseboard extends board {    // build board of specified size empty of tiles   public denseboard(int rows, int cols){       super(rows, cols);   }    // build board copies 2d array of tiles provided tiles   // immutable can referenced without copying   // fresh copy of 2d array must created internal use   // board.   public denseboard(tile t[][]){       board myboard = new denseboard(t.length, t[0].length);   } 

class board

package game2048;  public abstract class board{    protected int rows;   protected int cols;     public board(int rows, int cols){       this.rows = rows;       this.cols = cols;   }   // create distinct copy of board including internal tile   // positions , other state   public abstract board copy();    // return number of rows in board   public abstract int getrows();    // return number of columns in board   public abstract int getcols();    // return how many tiles present in board (non-empty spaces)   public abstract int gettilecount();    // return how many free spaces in board   public abstract int getfreespacecount();    // tile @ particular location   public abstract tile tileat(int i, int j);    // true if last shift operation moved tile; false otherwise   public abstract boolean lastshiftmovedtiles();    // return true if shift left, right, up, or down merge   // tiles. if no shift cause tiles merge, return false.   // inability merge part of determining if   // game over.   public abstract boolean mergepossible();    // add given tile board @ "freei"th free space.   public abstract void addtileatfreespace(int freei, tile tile);    // shift tiles of board in various directions.  tiles   // collide , should merged should changed internally in   // board.  shifts remove tiles, never add anything.  shift   // methods set state of board internally   // subsequent call lastshiftmovedtiles() return true if   // tile moved , false otherwise.  methods return score   // generated shift sum of scores   // tiles merged during shift. if no tiles merged,   // return score 0.   public abstract int shiftleft();   public abstract int shiftright();   public abstract int shiftup();   public abstract int shiftdown();  } 

you can send values parent class.

public denseboard(tile t[][]){       super(t.length, t[0].length);  } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -