samedi 7 mars 2015

What's wrong with the constructor?



Why is it giving an error in the line treasureLocations[] = new Coord(rows, cols); of the concstructor?



public class TreasureMap{
int rows, cols; // How big is the treasure map
Coord [] treasureLocations; // The locations of treasures

Scanner kbd = new Scanner(System.in);
// Prompt the user for info on the treasure map and then create it
// COMPLETE THIS METHOD
public TreasureMap(){

System.out.println("Enter the map size (2 ints): ");
rows = kbd.nextInt();
cols = kbd.nextInt();
treasureLocations[] = new Coord(rows, cols);




public class Coord {
public final int row;
public final int col;

// Constructor,
public Coord(int ir, int ic){
this.row = ir;
this.col = ic;
}



Aucun commentaire:

Enregistrer un commentaire