Question
In C++ Need the pieces to move across the checkerboard, need to implement the code so that two players can play main.cpp #include #include CheckersBoard.cpp
In C++
Need the pieces to move across the checkerboard, need to implement the code so that two players can play
main.cpp
#include
CheckersBoard.cpp
#include
using namespace std;
char Board[8][8] = { {' ', 'b', ' ', 'b', ' ', 'b', ' ', 'b'}, {'b', ' ', 'b', ' ', 'b', ' ', 'b', ' '}, {' ', 'b', ' ', 'b', ' ', 'b', ' ', 'b'}, {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, {'r', ' ', 'r', ' ', 'r', ' ', 'r', ' '}, {' ', 'r', ' ', 'r', ' ', 'r', ' ', 'r'}, {'r', ' ', 'r', ' ', 'r', ' ', 'r', ' '} };
void printBoard(){ cout<<" A B C D E F G H "< void player1move() { int x, y, xpos, ypos, xpos2, ypos2; string player1; cout << "Enter player 1 name: " << endl; cin >> player1; cout << player1 << " turn" << endl; cout << "Enter the coordinates( column, row) you want to move from: " << endl; cin >> ypos; char y1 = int(ypos)-1; cin >> xpos; int x1 = xpos-1; /* switch (ypos) { case '1': x = 0; case '2': x = 1; case '3': x = 2; case '4': x = 3; case '5': x = 4; case '6': x = 5; case '7': x = 6; case '8': x = 7; // default: // cout << " re-enter coordinates: " << endl; // cin >> ypos >> xpos; } switch (xpos) { case '1': y = 0; case '2': y = 1; case '3': y = 2; case '4': y = 3; case '5': y = 4; case '6': y = 5; case '7': y = 6; case '8': y = 7; //default: // cout<< " re-enter coordinates: "< cout << " Enter the coordinates you would like to move to: " << endl; cin >> ypos2 >> xpos2; switch (ypos2) { case '1': x = 0; case '2': x = 1; case '3': x = 2; case '4': x = 3; case '5': x = 4; case '6': x = 5; case '7': x = 6; case '8': x = 7; default: cout << " re-enter coordinates: " << endl; cin >> ypos2 >> xpos2; } switch (xpos2) { case '1': y = 0; case '2': y = 1; case '3': y = 2; case '4': y = 3; case '5': y = 4; case '6': y = 5; case '7': y = 6; case '8': y = 7; default: cout << " re-enter coordinates: " << endl; cin >> ypos2 >> xpos2; } printBoard(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started