hi i am making a 16puzzle game and i keep getting error about parameter conversion in main function. maybe someone can help me out and figure out whats wrong? i had this program written with functions and it worked perfectly,but now making it with classes(coz my teacher requires classes in this project). maybe someone can help me out and fix the problems that are here? thank you!
the main function works untill line "obj.Move(Board, eNextMove);" and it keeps on giving me error.
main.cpp file
#include <iostream>
#include <ctime>
#include <windows.h>
#include "boardclass.h"
using namespace std;
int main() {
puzzle obj;
obj.InitializeBoard();
obj.Randomize();
char Board[4][4];
enum EMove { keUp = 'w',
keDown = 's',
keLeft = 'a',
keRight = 'd'};
do {
obj.PrintBoard();
cout << endl << "w = Up, s = Down, a = Left, d = Right" << endl;
char cNextMove;
cin >> cNextMove;
EMove eNextMove = (EMove)cNextMove;
obj.Move(Board, eNextMove);
cout << endl;
system("cls");
} while (true);
cout << "Baigta" << endl;
return 0;
}
board.cpp file
#include <iostream>
#include <ctime>
#include <windows.h>
#include "boardclass.h"
void puzzle :: InitializeBoard() {
const char Initial[4][4] = {
{'1', '2', '3', '4'},
{'5', '6', '7', '8'},
{'9', 'A', 'B', 'C'},
{'D', 'E', 'F', ' '}
};
for (int Row = 0; Row < 4; ++Row) {
for (int Col = 0; Col < 4; ++Col) {
Board[Row][Col] = Initial[Row][Col];
}
}
}
void puzzle :: Randomize() {
srand((unsigned int)time(0));
for (int iIndex = 0; iIndex < 1000; ++iIndex) {
const int kiNextMove = (rand() % 4);
switch (kiNextMove) {
case 0:
{
Move(Board, keUp);
break;
}
case 1:
{
Move(Board, keDown);
break;
}
case 2:
{
Move(Board, keLeft);
break;
}
case 3:
{
Move(Board, keRight);
break;
}
}
}
}
void puzzle:: PrintBoard() {
for (int Row = 0; Row < 4; ++Row) {
for (int Col = 0; Col < 4; ++Col) {
cout << Board[Row][Col];
}
cout << endl;
}
}
void puzzle :: LocateSpace(int& irRow, int& irCol, char Board[4][4]) {
for (int Row = 0; Row < 4; ++Row) {
for (int Col = 0; Col < 4; ++Col) {
if (Board[Row][Col] == ' ') {
irRow = Row;
irCol = Col;
}
}
}
}
void puzzle :: Move(char Board[4][4], const EMove keMove) {
int RowSpace;
int ColSpace;
LocateSpace(RowSpace, ColSpace, Board);
int RowMove(RowSpace);
int ColMove(ColSpace);
switch (keMove) {
case keUp:
{
RowMove = RowSpace - 1;
break;
}
case keDown:
{
RowMove = RowSpace + 1;
break;
}
case keLeft:
{
ColMove = ColSpace - 1;
break;
}
case keRight:
{
ColMove = ColSpace + 1;
break;
}
}
if (RowMove >= 0 && RowMove < 4 && ColMove >= 0 && ColMove < 4) {
Board[RowSpace][ColSpace] = Board[RowMove][ColMove];
Board[RowMove][ColMove] = ' ';
}
}
boardclass.h file
#include <iostream>
#include <ctime>
#include <windows.h>
using namespace std;
class puzzle
{
char Board[4][4];
char cNextMove;
int eNextMove;
int Row;
int Col;
enum EMove { keUp = 'w',
keDown = 's',
keLeft = 'a',
keRight = 'd'};
public:
void puzzle :: PrintBoard();
void puzzle :: Move(char Board[4][4], const EMove keMove);
void puzzle :: Randomize();
void puzzle :: LocateSpace(int& irRow, int& irCol, char Board[4][4]);
void puzzle :: InitializeBoard();
};