Checkers Program

Using classes and pointers to run a 1 move checker piece

Page 1 of 1

5 Replies - 4097 Views - Last Post: 27 April 2009 - 01:59 AM Rate Topic: -----

#1 msitko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-March 09

Checkers Program

Post icon  Posted 25 April 2009 - 02:33 PM

Quote

I keep getting errors to where pointers should be referred to. Can someone help show me where the pointers should be correctly referrenced to. I need help with the debugging, and there are multiple errors that constantly show up.

Quote

Directions

Write class Piece

Declare it to have member variables: Name: Type:
teamPtr a pointer of type Team
row an integer
col an integer
(Should these vars be public or private?)
Declare but do not define a default and copy constructor.
Please make them private.
Because we are not writing them we do this so that any attempts to use them will be illegal!
This is good C++ technique.
Constructor Piece (Team* newTeamPtr, int newRow, int newCol) should:
Set teamPtr to newTeamPtr
Set row to newRow
Set col to newCol
A destructor that does nothing.
A const accessor for teamPtr called getTeamPtr(). (What type does it return?) It needs no parameters.
A const accessor for row called getRow(). (What type does it return?) It needs no parameters.
A const accessor for col called getCol(). (What type does it return?) It needs no parameters.
A void returning mutator for row called setRow(int i). (What should it do to row?) (Should it be const?)
A void returning mutator for col called setCol(int i). (What should it do to col?) (Should it be const?)
A bool returning method called getCanAdvance().
It should return true if row does not equal getTeamPtr()->getEndingRow() or false otherwise.
It should be a const method.
A bool returning method called getCanGoLeft().
It should return true if getCanAdvance() is true and col is greater than MIN_INTERNAL_COL.
It should return false otherwise.
It should be a const method.
A bool returning method called getCanGoRight().
It should return true if getCanAdvance() is true and col is less than MAX_INTERNAL_COL.
It should return false otherwise.
It should be a const method.
A void returning method called advanceLeft().
Only if getCanGoLeft() is true it should:
Erase its old position on the board (set it equal to NULL)
(Question: How do you do that? Hint: Look at the methods for Board)
(2nd Question: But how do I access the board? All I have are the row, column and team. Hint: Look at the methods for Team)
Update row by adding the team's direction.
Update col by subtracting 1.
Set the piece down in the new location on the board.
A void returning method called advanceRight().
Only if getCanGoRight() is true it should:
Erase its old position on the board (set it equal to NULL)
Update row by adding the team's direction.
Update col by adding 1.
Set the piece down in the new location on the board.
Write class Team (Points 30)
Declare it to have member variables: Name: Type:
boardPtr a pointer of type Board
direction an integer
piecePtr a pointer of type Piece
(Should these vars be public or private?)
Declare but do not define a default and copy constructor.
Please make them private.
Because we are not writing them we do this so that any attempts to use them will be illegal!
This is good C++ technique.
A constructor Team (Board* boardPtr, int newDir) that:
Sets boardPtr to newBoardPtr.
Sets piecePtr to new Piece(this,MIN_INTERNAL_ROW,MAX_INTERNAL_COL)
Sets direction to newDir.
Updates the board to place the new piece at its location.
(Question: How do you do that? Hint: Look at the methods for Board)
A destructor (What, if anything, should it destroy?)
A const accessor for boardPtr called getBoardPtr(). (What type does it return?) It needs no parameters.
A const accessor for direction called getDirection(). (What type does it return?) It needs no parameters.
A const accessor for piecePtr called getPiecePtr(). (What type does it return?) It needs no parameters.
An int returning method called getEndingRow() that is const. It should return MAX_INTERNAL_ROW if direction equals POS_DIRECTION or MIN_INTERNAL_ROW otherwise.
Write class Board (Points 30)
Declare it to have member variables: Name: Type:
array board[NUM_EXTERNAL_ROWS][NUM_EXTERNAL_COLS] pointers of type Piece
teamPtr a pointer of type Team
(Should these vars be public or private?)
Declare but do not define a copy constructor.
Please make them private.
Because we are not writing them we do this so that any attempts to use them will be illegal!
This is good C++ technique.
A default constructor that should:
Set all NUM_EXTERNAL_ROWS by NUM_EXTERNAL_COLS elements of board[][] to NULL.
Sets teamPtr to new Team(this,POS_DIRECTION)
A destructor that delete()s all elements of array board[][] as well as teamPtr.
A void returning method called setPiece (Piece* piecePtr, int row, int col) that sets board[row][col] to piecePtr.


Quote

Main.cpp program

 
/*-------------------------------------------------------------------------*
 *---																   ---*
 *---		 main.cpp												  ---*
 *---																   ---*
 *---	  This file defines the functions and objects that control	 ---*
 *---   the overall play of the checkers program.					   ---*
 *---																   ---*
 *---   ----	----	----	----	----	----	----	----	---*
 *---																   ---*
 *---   Version 1.0			 2009 April 14		   Joseph Phillips ---*
 *---																   ---*
 *-------------------------------------------------------------------------*/

#include "stdafx.h"
#include <iostream>
#include "headers.h"

using namespace std;

int	 main ()

{
  Board   board;
  string  line;
  bool	isGoingLeft = true;

  while  ( true )
  {
	board.show();

	if  ( !board.getTeamPtr()->getPiecePtr()->getCanAdvance() )
	  break;

	cout << endl << "\t\tPlease press enter " << endl;
	getline(cin,line);

	if  (isGoingLeft)
	{
	  if  (board.getTeamPtr()->getPiecePtr()->getCanGoLeft())
	board.getTeamPtr()->getPiecePtr()->advanceLeft();
	  else
	  {
	isGoingLeft = false;
	board.getTeamPtr()->getPiecePtr()->advanceRight();
	  }
	}
	else
	{
	  if  (board.getTeamPtr()->getPiecePtr()->getCanGoRight())
	board.getTeamPtr()->getPiecePtr()->advanceRight();
	  else
	  {
	isGoingLeft = true;
	board.getTeamPtr()->getPiecePtr()->advanceLeft();
	  }
	}

  }

  return(0);
}



Quote

const.header file

/*-------------------------------------------------------------------------*
 *---																   ---*
 *---		 consts.h												  ---*
 *---																   ---*
 *---	  This file defines the global constants used by the checkers  ---*
 *---   program.														---*
 *---																   ---*
 *---   ----	----	----	----	----	----	----	----	---*
 *---																   ---*
 *---   Version 1.0			 2009 April 16		   Joseph Phillips ---*
 *---																   ---*
 *-------------------------------------------------------------------------*/


const int POS_DIRECTION	 = +1;

const int NEG_DIRECTION	 = -1;

const int NUM_EXTERNAL_ROWS = 10;

const int MIN_EXTERNAL_ROW  = 0;

const int MAX_EXTERNAL_ROW  = NUM_EXTERNAL_ROWS - 1;

const int NUM_INTERNAL_ROWS = NUM_EXTERNAL_ROWS - 2;

const int MIN_INTERNAL_ROW  = MIN_EXTERNAL_ROW + 1;

const int MAX_INTERNAL_ROW  = MAX_EXTERNAL_ROW - 1;

const int NUM_EXTERNAL_COLS = 10;

const int MIN_EXTERNAL_COL  = 0;

const int MAX_EXTERNAL_COL  = NUM_EXTERNAL_COLS - 1;

const int NUM_INTERNAL_COLS = NUM_EXTERNAL_COLS - 2;

const int MIN_INTERNAL_COL  = MIN_EXTERNAL_COL + 1;

const int MAX_INTERNAL_COL  = MAX_EXTERNAL_COL - 1;



Quote

header.h file

/*-------------------------------------------------------------------------*
 *---																   ---*
 *---		 headers.h												 ---*
 *---																   ---*
 *---	  This file includes all headers in the proper sequence for	---*
 *---   the checkers program.										   ---*
 *---																   ---*
 *---   ----	----	----	----	----	----	----	----	---*
 *---																   ---*
 *---   Version 1.0			 2009 April 14		   Joseph Phillips ---*
 *---																   ---*
 *-------------------------------------------------------------------------*/

#include <iostream>
#include <string>

using namespace std;

#include "consts.h"

class   Team;
class   Board;

#include "Piece.h"
#include "Team.h"
#include "Board.h"



Quote

Board.h file

class Board
{
private:
	Piece board[NUM_EXTERNAL_ROWS][NUM_EXTERNAL_COLS];
	Team* teamPtr;

	Board(const Board&);				//Copy constructor

};



Quote

Board.cpp file

#include "stdafx.h"
#include "headers.h"

public:
	Board::Board()								//Default constructor
	{
		board[][]=NULL;
		Team.teamPtr=newTeam(this, POS_DIRECTION);
	}
	~Board::Board()
	{
		delete [] board[][];
		delete() Team.teamPtr;
	}

	void Board::setPiece(Piece* piecePtr, int row, int col)
	{
		board[row][col]=piecePtr;
	}

/*  PURPOSE:  To display the board.  No parameters.  No return value. */

void	Board :: show () const
{
  int row;
  int subRow;
  int col;
  int subCol;

  for  (row = MIN_INTERNAL_ROW;  row <= MAX_INTERNAL_ROW;  row++)
  {

	for  (subRow = 0;  subRow <= 6;  subRow++)
	{

	  for  (col = MIN_INTERNAL_COL;  col <= MAX_INTERNAL_COL;  col++)
	  {
	char borderChar = ((row + col) % 2) ? ' ' : '.';
	char spacerChar = (col == MAX_INTERNAL_COL) ? '\n' : ' ';

	switch (subRow)
	{
	case 0 :
	case 6 :
	  for  (subCol = 0;  subCol < 7;  subCol++)
		cout << borderChar;
	  break;

	case 1 :
	case 5 :
	  cout << borderChar;
	  for  (subCol = 1;  subCol < 6;  subCol++)
		cout << ' ';
	  cout << borderChar;
	  break;

	case 2 :
	case 3 :
	case 4 :
	  cout << borderChar;

	  if  (board[row][col] == NULL)
		cout << "	 ";
	  else
		cout << " XXX ";

	  cout << borderChar;
	  break;
	}

	cout << spacerChar;

	  }

	}

  }

}




Quote

Team.h file

class Team
{
private:
	Board* boardPtr;
	int direction;
	Piece* piecePtr;

	//C
	Team();											//Default constructor
	Team(const Team&);								//Copy constructor

public:

	//E
	~Team(){ }										//Destructor

	//F,G,H
	Board* getBoardPtr() const {return(boardPtr);}	//Accessor
	int getDirection() const {return(direction);}	//Accessor
	Piece* getPiecePtr() const {return(piecePtr);}	//Accessor

	//I	
};



Quote

Team.cpp

#include "stdafx.h"
#include "headers.h"



	Team::Team(Board* boardPtr, int newDir)
	{
		boardPtr=newBoardPtr;
		piecePtr=newPiece(this, MIN_INTERNAL_ROW, MAX_INTERNAL_COL);
		Team.direction=newDir;

		/*Updates board to place the new pieces at its location*/
		//INSERT CODE HERE//
	}

	const int Team::getEndingRow()
	{
		if((direction)==((POS_DIRECTION)||(MIN_INTERNAL_ROW))
		{
			return (MAX_INTERNAL_ROW);
		}
	}



Quote

Piece.h file

class Piece
{
private:
	Team* teamPtr;
	int row;
	int col;

	Piece();									//Default constructor
	Piece(const Piece&);						//Copy constructor

public:
	/*Piece(Team* newTeamPtr, int newRow, int newCol)
	{
		teamPtr=newTeamPtr;
		row=newRow;
		col=newCol;
	}*/	//INCLUDED IN .CPP

	~Piece() {}									//Destructor

	Team* getTeamPtr() const {return(teamPtr);}	//Accessor
	int getRow() const {return(row);}			//Accessor
	int getCol() const {return(col);}			//Accessor

	void setRow(int i) {row=i;}					//Mutator
	void setCol(int i) {col=i;}					//Mutator

	//K
	/*
	const bool getCanAdvance()					
	{
		if(row!=(getTeamPtr->getEndingRow()) )
			return (true);
		else
			return (false);
	}

	//L
	const bool getCanGoLeft()					
	{
		if((col>MIN_INTERNAL_COL)&&(getCanAdvance==true))
			return true;
		else
			return false;
	}

	//M
	const bool getCanGoRight()					
	{
		if((getCanAdvance()==true)&&(col<MAX_INTERNAL_COL))
			return true;
		else
			return false;
	}

	//N
	void Piece::advanceLeft()					
	{
		if(getCanGoLeft()==true)
		{
			teamPtr->getBoardPtr()->setPiece(NULL, getRow(), getCol());
			row+=teamPtr->getDirection();
			col--;
			teamPtr->getBoardPtr()->setPiece(this, getRow(), getCol());
		}
	}

	//O
	void Piece::advanceRight()
	{
		if(getCanGoRight()==true)
		{
			teamPtr->getBoardPtr()->setPiece(NULL, getRow(), getCol());
			row+=teamPtr->getDirection();
			col++;
			teamPtr->getBoardPtr()->setPiece(this, getRow(), getCol());
		}
	}
*/
};



Quote

Piece.cpp file

#include "stdafx.h"
#include "headers.h"

	Piece::Piece(Team* newTeamPtr, int newRow, int newCol)
	{
		teamPtr=newTeamPtr;
		row=newRow;
		col=newCol;
	}

	const bool Piece::getCanAdvance()					
	{
		if(row!=(getTeamPtr->getEndingRow()) )
			return (true);
		else
			return (false);
	}

	const bool Piece::getCanGoLeft()					
	{
		if((col>MIN_INTERNAL_COL)&&(getCanAdvance==true))
			return true;
		else
			return false;
	}

	//M
	const bool Piece::getCanGoRight()					
	{
		if((getCanAdvance()==true)&&(col<MAX_INTERNAL_COL))
			return true;
		else
			return false;
	}

	//N
	void Piece::advanceLeft()					
	{
		if(getCanGoLeft()==true)
		{
			teamPtr->getBoardPtr()->setPiece(NULL, getRow(), getCol());
			row+=teamPtr->getDirection();
			col--;
			teamPtr->getBoardPtr()->setPiece(this, getRow(), getCol());
		}
	}

	//O
	void Piece::advanceRight()
	{
		if(getCanGoRight()==true)
		{
			teamPtr->getBoardPtr()->setPiece(NULL, getRow(), getCol());
			row+=teamPtr->getDirection();
			col++;
			teamPtr->getBoardPtr()->setPiece(this, getRow(), getCol());
		}
	}


This post has been edited by msitko: 25 April 2009 - 02:40 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Checkers Program

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Checkers Program

Posted 25 April 2009 - 02:52 PM

Tell us what the errors you are getting are.
Was This Post Helpful? 0
  • +
  • -

#3 msitko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-March 09

Re: Checkers Program

Posted 25 April 2009 - 05:08 PM

View Postjanotte, on 25 Apr, 2009 - 01:52 PM, said:

Tell us what the errors you are getting are.


Quote

1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(23) : error C2512: 'Board' : no appropriate default constructor available
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(29) : error C2039: 'show' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(31) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(31) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(31) : error C2227: left of '->getCanAdvance' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(39) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(39) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(39) : error C2227: left of '->getCanGoLeft' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(40) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(40) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(40) : error C2227: left of '->advanceLeft' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(44) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(44) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(44) : error C2227: left of '->advanceRight' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(49) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(49) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(49) : error C2227: left of '->getCanGoRight' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(50) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(50) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(50) : error C2227: left of '->advanceRight' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(54) : error C2039: 'getTeamPtr' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(54) : error C2227: left of '->getPiecePtr' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(54) : error C2227: left of '->advanceLeft' must point to class/struct/union/generic type
1>Board.cpp
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(4) : error C2059: syntax error : 'public'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(6) : error C2511: 'Board::Board(void)' : overloaded member function not found in 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(10) : error C2061: syntax error : identifier '{ctor}'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(11) : error C2143: syntax error : missing ';' before '{'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(11) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(16) : error C2039: 'setPiece' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(18) : error C2065: 'board' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(23) : error C2039: 'show' : is not a member of 'Board'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.h(2) : see declaration of 'Board'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(24) : error C2270: 'show' : modifiers not allowed on nonmember functions
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\board.cpp(62) : error C2065: 'board' : undeclared identifier
1>Piece.cpp
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(5) : error C2511: 'Piece::Piece(Team *,int,int)' : overloaded member function not found in 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(11) : error C2039: 'getCanAdvance' : is not a member of 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(13) : error C2065: 'row' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(13) : error C2065: 'getTeamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(13) : error C2227: left of '->getEndingRow' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(19) : error C2039: 'getCanGoLeft' : is not a member of 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(21) : error C2065: 'col' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(21) : warning C4805: '==' : unsafe mix of type 'const bool (__cdecl *)(void)' and type 'bool' in operation
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(21) : error C2446: '==' : no conversion from 'int' to 'const bool (__cdecl *)(void)'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(21) : error C2040: '==' : 'const bool (__cdecl *)(void)' differs in levels of indirection from 'int'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(28) : error C2039: 'getCanGoRight' : is not a member of 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(30) : error C2065: 'col' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(37) : error C2039: 'advanceLeft' : is not a member of 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(41) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(41) : error C2227: left of '->getBoardPtr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(41) : error C2227: left of '->setPiece' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(41) : error C3861: 'getRow': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(41) : error C3861: 'getCol': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(42) : error C2065: 'row' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(42) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(42) : error C2227: left of '->getDirection' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(43) : error C2065: 'col' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C2227: left of '->getBoardPtr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C2227: left of '->setPiece' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C2673: 'advanceLeft' : global functions do not have 'this' pointers
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C3861: 'getRow': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(44) : error C3861: 'getCol': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(49) : error C2039: 'advanceRight' : is not a member of 'Piece'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.h(2) : see declaration of 'Piece'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(53) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(53) : error C2227: left of '->getBoardPtr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(53) : error C2227: left of '->setPiece' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(53) : error C3861: 'getRow': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(53) : error C3861: 'getCol': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(54) : error C2065: 'row' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(54) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(54) : error C2227: left of '->getDirection' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(55) : error C2065: 'col' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C2065: 'teamPtr' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C2227: left of '->getBoardPtr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C2227: left of '->setPiece' must point to class/struct/union/generic type
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C2673: 'advanceRight' : global functions do not have 'this' pointers
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C3861: 'getRow': identifier not found
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\piece.cpp(56) : error C3861: 'getCol': identifier not found
1>Team.cpp
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.cpp(7) : error C2511: 'Team::Team(Board *,int)' : overloaded member function not found in 'Team'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.h(2) : see declaration of 'Team'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.cpp(16) : error C2039: 'getEndingRow' : is not a member of 'Team'
1> c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.h(2) : see declaration of 'Team'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.cpp(18) : error C2065: 'direction' : undeclared identifier
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.cpp(19) : error C2143: syntax error : missing ')' before '{'
1>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\team.cpp(19) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation
1>Generating Code...
1>Build log was saved at "file://c:\Users\Mike\Documents\Visual Studio 2008\Projects\Assignment2\Assignment2\Debug\BuildLog.htm"
1>Assignment2 - 80 error(s), 2 warning(s)

This post has been edited by msitko: 25 April 2009 - 05:10 PM

Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Checkers Program

Posted 25 April 2009 - 11:26 PM

Let's have a look at this one

Quote

>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(23) : error C2512: 'Board' : no appropriate default constructor available


In your code you have this
int main () {
	  Board   board;



Which expects the default constructor you haven't yet written.
You have supplied a copy constructor but no default constructor.

Define it like this
Board();
and write a function in your implementation
Board::Board() {
// your code here
}


Read more here:
http://www.cplusplus...torial/classes/

This post has been edited by janotte: 25 April 2009 - 11:27 PM

Was This Post Helpful? 1

#5 msitko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-March 09

Re: Checkers Program

Posted 26 April 2009 - 10:51 AM

View Postjanotte, on 25 Apr, 2009 - 10:26 PM, said:

Let's have a look at this one

Quote

>c:\users\mike\documents\visual studio 2008\projects\assignment2\assignment2\assignment2.cpp(23) : error C2512: 'Board' : no appropriate default constructor available


In your code you have this
int main () {
	  Board   board;



Which expects the default constructor you haven't yet written.
You have supplied a copy constructor but no default constructor.

Define it like this
Board();
and write a function in your implementation
Board::Board() {
// your code here
}


Read more here:
http://www.cplusplus...torial/classes/


Quote

Thank you for the help. It's very much appreciated

Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Checkers Program

Posted 27 April 2009 - 01:59 AM

Not a worry.

Come back with more questions if you still have more errors/problems once you have worked on this one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1