Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include "CheckersBoard.cpp" int main() { printBoard(); player1move(); std::cout << "Hello, World!" << std::endl; return 0; }

CheckersBoard.cpp

#include #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: "<>ypos>>xpos; }*/ Board[y][x] = ' '; printBoard();

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Who are our competitors?

Answered: 1 week ago

Question

Proximity of the brain tissue?

Answered: 1 week ago

Question

Human brain are.......?

Answered: 1 week ago

Question

How many lobes are in the cerebral cortex?

Answered: 1 week ago

Question

The central nervous system?

Answered: 1 week ago