// board.h
// Header file for board class
#pragma once
#include<iostream>
#include<vector>
#include<cstdlib> // for NULL
#include<map>
#include"player.h"
using namespace std;
class board
{
public:
// Default Constructor
board();
// Copy Constructor
// Takes two ints, and creates a board of that size. row==col for all inputs
board(int row, int col);
// Index operator
const vector<int>& operator[](int row);
// Insert
bool insert(int ID, int row, int column);
// Remove
bool remove(int ID);
// Find
bool find(int ID);
// Find with Pos
void findWithPos(int& row, int& col);
// Move to
bool moveTo(int ID, int row, int column);
// Print by coordinate
void printByCoordinate();
// Print by ID
void printByID();
private:
map<int, player> mapByCoord; // Map where the key is the x value of the coordinate, and the value is a player
map<int, player> mapByID; // Map where the key is an ID number, and the value is a player
int numPlayers; // Keep track of the number of players in the game
};
=======================
// board.cpp
// Implementation file for board class
#include "board.h"
board::board()
{
numPlayers=0;
}
board::board(int row, int col)
{
numPlayers = 0;
// Don't think I need anything here,
// because maps are STL objects dynamic
// so size can be adjusted on the fly
}
board::insert(int ID, int row, int column)
{
player(ID) p1;
mapByID.insert(pair<int, int>(ID, row));
mapByCoord.insert(pair<int, int>(row, ID));
}
and here is my player class.. which I'm not really done with
// player.h
// Header file for player class
class player
{
public:
player();
player(int ID);
private:
int ID; // Must be unique, positive, and will occupy a unique (x,y) position on the board.
};
==============================
// player.cpp
// player class implementation
#include"player.h"
player::player()
{
}
player::player(int ID1)
{
ID = ID1;
}
Any help is appreciated, even just a shove in the right direction. Thanks in advance

New Topic/Question
Reply




MultiQuote


|