15Slide
Grid15::Grid Class Reference

A data type consisting of a 4 by 4 grid array, and a 16 by 2 index, for use with 15Slide. More...

#include <Grid.h>

Public Types

typedef std::array< std::array< std::uint8_t, 4 >, 4 > gridArray_t
 The type used for Grid::gridArray. More...
 
typedef std::array< std::array< std::uint8_t, 2 >, 16 > index_t
 The type used for Grid::index. More...
 

Public Member Functions

 Grid ()
 Creates a new Grid, leaving everything uninitialized. More...
 
 Grid (const gridArray_t &newGrid)
 Creates a new Grid and copies a grid array to it. More...
 
 Grid (const index_t &newIndex)
 Creates a new Grid and copies an index to it. More...
 
 Grid (const gridArray_t &newGrid, const index_t &newIndex)
 Creates a new Grid and copies a grid array and an index to it. More...
 
 Grid (const Grid &other)
 Creates and copies a new Grid. More...
 
Gridoperator= (const Grid &other)
 Copies a Grid. More...
 
void setGridArray (const gridArray_t &newGrid)
 Sets Grid::grid. More...
 
void setGrid (const Grid &newGrid)
 Copies a Grid. More...
 
void setIndex (const index_t &newIndex)
 Sets Grid::index. More...
 

Public Attributes

gridArray_t gridArray {}
 The grid. More...
 
index_t index {}
 The index to keep track of tile locations. More...
 

Static Public Attributes

static constexpr std::size_t NO_TILE {0}
 The number representing the lack of a tile. More...
 
static constexpr std::size_t TILE_MAX {15}
 The maximum tile number. More...
 
static constexpr std::size_t TILE_MIN {0}
 The mininum tile number. More...
 
static constexpr std::size_t Y_MAX {3}
 The maximum y coordinate. More...
 
static constexpr std::size_t Y_MIN {0}
 The mininum x coordinate. More...
 
static constexpr std::size_t X_MAX {3}
 The maximum x coordinate. More...
 
static constexpr std::size_t X_MIN {0}
 The mininum x coordinate. More...
 
static constexpr gridArray_t GOAL_GRID
 How the gridArray should be when the game is won. More...
 

Detailed Description

A data type consisting of a 4 by 4 grid array, and a 16 by 2 index, for use with 15Slide.

Author
John Jekel
Date
2018-2018

Member Typedef Documentation

◆ gridArray_t

typedef std::array<std::array<std::uint8_t, 4>, 4> Grid15::Grid::gridArray_t

The type used for Grid::gridArray.

◆ index_t

typedef std::array<std::array<std::uint8_t, 2>, 16> Grid15::Grid::index_t

The type used for Grid::index.

Constructor & Destructor Documentation

◆ Grid() [1/5]

Grid15::Grid::Grid ( )

Creates a new Grid, leaving everything uninitialized.

◆ Grid() [2/5]

Grid15::Grid::Grid ( const gridArray_t newGrid)

Creates a new Grid and copies a grid array to it.

Parameters
newGridThe new grid array

◆ Grid() [3/5]

Grid15::Grid::Grid ( const index_t newIndex)

Creates a new Grid and copies an index to it.

Parameters
newIndexThe new index

◆ Grid() [4/5]

Grid15::Grid::Grid ( const gridArray_t newGrid,
const index_t newIndex 
)

Creates a new Grid and copies a grid array and an index to it.

Parameters
newGridThe new grid array
newIndexThe new index

◆ Grid() [5/5]

Grid15::Grid::Grid ( const Grid newGrid)

Creates and copies a new Grid.

Parameters
newGridThe new Grid

Member Function Documentation

◆ operator=()

Grid & Grid15::Grid::operator= ( const Grid newGrid)

Copies a Grid.

Parameters
newGridThe new Grid

◆ setGrid()

void Grid15::Grid::setGrid ( const Grid newGrid)

Copies a Grid.

Parameters
newGridThe new grid

◆ setGridArray()

void Grid15::Grid::setGridArray ( const gridArray_t newGrid)

Sets Grid::grid.

Parameters
newGridThe new grid array to use

◆ setIndex()

void Grid15::Grid::setIndex ( const index_t newIndex)

Sets Grid::index.

Parameters
newIndexThe new index array to use

Member Data Documentation

◆ GOAL_GRID

constexpr gridArray_t Grid15::Grid::GOAL_GRID
static
Initial value:
{
{
{1, 2, 3, 4,},
{5, 6, 7, 8,},
{9, 10, 11, 12,},
{13, 14, 15, Grid::NO_TILE}
}
}

How the gridArray should be when the game is won.

◆ gridArray

gridArray_t Grid15::Grid::gridArray {}

The grid.

◆ index

index_t Grid15::Grid::index {}

The index to keep track of tile locations.

◆ NO_TILE

constexpr std::size_t Grid15::Grid::NO_TILE {0}
static

The number representing the lack of a tile.

◆ TILE_MAX

constexpr std::size_t Grid15::Grid::TILE_MAX {15}
static

The maximum tile number.

◆ TILE_MIN

constexpr std::size_t Grid15::Grid::TILE_MIN {0}
static

The mininum tile number.

◆ X_MAX

constexpr std::size_t Grid15::Grid::X_MAX {3}
static

The maximum x coordinate.

◆ X_MIN

constexpr std::size_t Grid15::Grid::X_MIN {0}
static

The mininum x coordinate.

◆ Y_MAX

constexpr std::size_t Grid15::Grid::Y_MAX {3}
static

The maximum y coordinate.

◆ Y_MIN

constexpr std::size_t Grid15::Grid::Y_MIN {0}
static

The mininum x coordinate.


The documentation for this class was generated from the following files: