The modifications are the assignment

Assignment Help Basic Computer Science
Reference no: EM13854292

Start with the base code given below. Get it to compile and run as shown. THEN, make the modifications shown below.

Important notes:

  • The modifications are the assignment!
  • This assignment will require you to think, research and explore, it is not a step-by-step!
  • Work on this assignment on your own!

BASE CODE:

#include <iostream>

#include <string>

#include <assert.h>

using namespace std;

const int NUM_ROWS = 8;

const int NUM_COLS = 8;

// **************** CLASS: CELL *******************

class Cell {

     char piece;

     char color;

public:

     Cell();

     void place(char color, char piece);

     string getPiece();

};

Cell::Cell() {

     piece = ' ';

     color = ' ';

}

void Cell::place(char newColor, char newPiece) {

     assert((newColor == 'W') || (newColor == 'B'));

     color = newColor;

     assert((newPiece == 'R') || (newPiece == 'K') ||

(newPiece == 'B') || (newPiece == 'Q') ||

(newPiece == 'K') || (newPiece == 'N') ||

(newPiece == 'P'));

     piece = newPiece;

}

string Cell::getPiece() {

     string result = "";

     result = result.append(1, color);

     result = result.append(1, piece);

     return result;

}

// **************** CLASS: BOARD *******************

class Board {

     Cell board[NUM_ROWS][NUM_COLS]; // <-- Not a good idea in the long run

     void displayLine();

public:

     Board();

     void displayBoard();

};

Board::Board() {

     board[0][0].place('B', 'R');

     board[0][1].place('B', 'N');

     board[0][2].place('B', 'B');

     board[0][3].place('B', 'Q');

     board[0][4].place('B', 'K');

     board[0][5].place('B', 'B');

     board[0][6].place('B', 'N');

     board[0][7].place('B', 'R');

     for (int c = 0; c < NUM_COLS; c++) {

          board[1][c].place('B', 'P');

     }

     board[NUM_COLS - 1][0].place('W', 'R');

     board[NUM_COLS - 1][1].place('W', 'N');

     board[NUM_COLS - 1][2].place('W', 'B');

     board[NUM_COLS - 1][4].place('W', 'K');

     board[NUM_COLS - 1][3].place('W', 'Q');

     board[NUM_COLS - 1][5].place('W', 'B');

     board[NUM_COLS - 1][6].place('W', 'N');

     board[NUM_COLS - 1][7].place('W', 'R');

     for (int c = 0; c < NUM_COLS; c++) {

          board[NUM_COLS-2][c].place('W', 'P');

     }

}

void Board::displayLine() {

     cout << endl;

     for (int x = 0; x < NUM_COLS; x++) {

          cout << "    | ";

     }

     cout << endl;

     for (int x = 0; x < NUM_COLS; x++) {

          cout << "----| ";

     }

     cout << endl;

}

void Board::displayBoard() {

     cout << endl << "CURRENT BOARD:" << endl << endl;

     for (int r = 0; r < NUM_ROWS; r++) {

          for (int c = 0; c < NUM_COLS; c++) {

              cout << " " << board[r][c].getPiece() << " | ";

          }

          displayLine();

     }

     cout << endl << endl;

}

int main() {

     Board board;

     board.displayBoard();

     return 0;

}

OUTPUT FROM BASE CODE:

CURRENT BOARD:

 BR |  BN |  BB |  BQ |  BK |  BB |  BN |  BR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 BP |  BP |  BP |  BP |  BP |  BP |  BP |  BP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WP |  WP |  WP |  WP |  WP |  WP |  WP |  WP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WR |  WN |  WB |  WQ |  WK |  WB |  WN |  WR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

MODIFICATIONS:

Add three lines to main as shown below. Modify the program by adding whatever is necessary to get it to work as shown in the output below.

NEW MAIN:

int main() {

     Board board;

     board.displayBoard();

     string piece = board.take(0, 1);

     board.place(2, 2, piece.at(0), piece.at(1));

     board.displayBoard();

     return 0;

}

NEW OUPUT:

CURRENT BOARD:

 BR |  BN |  BB |  BQ |  BK |  BB |  BN |  BR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 BP |  BP |  BP |  BP |  BP |  BP |  BP |  BP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WP |  WP |  WP |  WP |  WP |  WP |  WP |  WP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WR |  WN |  WB |  WQ |  WK |  WB |  WN |  WR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

CURRENT BOARD:

 BR |     |  BB |  BQ |  BK |  BB |  BN |  BR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 BP |  BP |  BP |  BP |  BP |  BP |  BP |  BP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |  BN |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

    |     |     |     |     |     |     |     |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WP |  WP |  WP |  WP |  WP |  WP |  WP |  WP |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 WR |  WN |  WB |  WQ |  WK |  WB |  WN |  WR |

    |     |     |     |     |     |     |     |

----| ----| ----| ----| ----| ----| ----| ----|

 

 

Reference no: EM13854292

Questions Cloud

Whos responsibility for what is being taught in our colleges : Who has the greater responsibility for what is being taught in our colleges--students, parents, primary and secondary schools, or the colleges themselves
Explain the meaning of variety management : Explain the meaning of variety management as used in operational management
Apply to multidimensional analysis : Which of the following statements does not apply to multidimensional analysis:Provides the most flexible type of reporting.Allows for drill up, drill down, and iterative data analysis.
Matrices-set of problems : Use the matrices defined below for the following set of problems.
The modifications are the assignment : The modifications are the assignment!This assignment will require you to think, research and explore, it is not a step-by-step!Work on this assignment on your own!
What is your financial analysis that supports your decision : How would you approach this opportunity? How would you determine customer interest, what would be your key assumptions, and what are the cheapest ways you can determine to test those assumptions?
What are precise effects of the engagement of an escort team : What are the precise effects of the engagement of an escort team representing the final end users during the execution of the project from the initial phase till the end?
Dependent and independent variables : State a good hypothesis, design an experiment (include test subjects, sample size, control(s), dependent and independent variables, type of data collected) and hypothetical results/conclusion. Does your conclusion support the hypothesis?
Construct a time series plot of all four variables : Construct a time series plot of all four variables and discuss your findings based on the graphs - Find the control limits for an X-bar and R chart if a new improved process has average of 50.5 lbs. and R-bar of 1.2 lbs. Assume n=5 for new process..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd