Grid.h

//
//  Created by Andrew Shidel on 4/30/13.
//  Creates a Grid object.
//

#ifndef __Grid_h
#define __Grid_h

#include <string>
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

class Grid {
    
public:
    //----------------------------------------------------------------------------
    //----- Constructors ---------------------------------------------------------
    //----------------------------------------------------------------------------
    
    
    //Main constructor.
    Grid();
    
    Grid(int width, int height);
    
    //----------------------------------------------------------------------------
    //----- Inspectors -----------------------------------------------------------
    //----------------------------------------------------------------------------
    
    int getWidth();
    
    int getHeight();
    
    //----------------------------------------------------------------------------
    //----- Mutators -------------------------------------------------------------
    //----------------------------------------------------------------------------
    
    void moveTo(int x, int y);
    
    
    //----------------------------------------------------------------------------
    //----- Facilitators ---------------------------------------------------------
    //----------------------------------------------------------------------------
    
    string toString();
    
    
    //Allows for use of the [] operator on a grid object.
    vector& operator[] (const int index);
    
    //----------------------------------------------------------------------------
    //----- Managers -------------------------------------------------------------
    //----------------------------------------------------------------------------
    

private:
    
    //A multidimentional vector to hold the values of each cell.
    vector< vector > cells_;
    
};


#endif

Grid.cpp


//
//  Created by Andrew Shidel on 4/30/13.
//  Implementation of Grid.h
//

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include "Grid.h"

using namespace std;

//----------------------------------------------------------------------------
//----- Constructors ---------------------------------------------------------
//----------------------------------------------------------------------------

//Default constructor to create a blank puzzle.
Grid::Grid(){
    vector  v(9,-1);
    for (int i = 0; i < 9; i++)
        cells_.push_back( v );
}

Grid::Grid(int width, int height){
    vector  v(height,-1);
    for (int i = 0; i < width; i++)
        cells_.push_back( v );
}


//----------------------------------------------------------------------------
//----- Inspectors -----------------------------------------------------------
//----------------------------------------------------------------------------

int Grid::getWidth(){
    
    return cells_.size();
}

int Grid::getHeight(){
    
    return cells_[0].size();
    
}


//----------------------------------------------------------------------------
//----- Mutators -------------------------------------------------------------
//----------------------------------------------------------------------------

void Grid::moveTo(int x, int y){
    
    
    
}


//----------------------------------------------------------------------------
//----- Facilitators ---------------------------------------------------------
//----------------------------------------------------------------------------


//Allows for use of the [] operator on a Grid object.
vector& Grid::operator[] (const int index){
    return cells_[index];
}

//----------------------------------------------------------------------------
//----- Managers -------------------------------------------------------------
//----------------------------------------------------------------------------