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

  Describe the reasons for disney''s adoption of itil

Describe the reasons for Disney's adoption of ITIL. Examine the results that were attained by Disney.

  Creating the walburg energy alternatives database

Complete In The Lab 2 - Creating the Walburg Energy Alternatives Database - on page AC 68 - AC 69 at the end of Access Chapter 1. Perform all steps. Submit the entire database file for grading.

  Create a pseudocode

Create a pseudocode using if instruction containing a compound condition that will satisfy the following:

  Dns is a commonly used service in the internet

1> DNS is a commonly used service in the Internet. Explain the roles of the local name servers, the authoritative name servers, and the root name servers.

  Modify testscoreappmath

Use the += operator to increase the scoreCount and scoreTotal variables. Then test this to makes sure it works.

  Which structure would be the best for the storyboard

Case 2-3 Michael wants to create a Website based on his famous cooking show. He would like to provide instructions on how to create some of his favorite dishes. He would like his recipes to be displayed in very simple, step by step pages.

  The human element

Human nature is the single greatest vulnerability in any control system and cannot be ignored. Organizations should always take human behavior into account when designing access plans and strategies. Human beings can pose unintentional threats when t..

  Describe object management group-s purpose-influence on uml

Investigate the Object Management Group (OMG). Discuss your findings. Describe what it is, its purpose, and its influence on UML and the object approach to systems development.

  Part of your first project

On completion of this course you are hired by the company Tickets R Us. Part of your first project is to develop an application to assist with the selling of tickets. After discussing with your client

  When using uml to describe the classes

When using UML to describe the classes, what is UML? What does a + or - signify

  Fi and rri notation illustrate

Using the Fi and RRi notation illustrate the transfer of 15 data packets with a window size of 5.

  Calculate the profit made on works of art

Calculate the profit made on works of art that have been sold (i.e., the profit/loss on an  individual work of art is the difference between the acquisition price and the sales price).

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