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

  A food distribution company ships fresh spinach

A food distribution company ships fresh spinach from its four packing plants to large East-coast cities. The shipping costs per crate, the supply and demand are shown in the table at the bottom of this page.

  Write specific formulas and functions

Consider the following scenario: As supervisor for a retail company, you supervise six people in your location. You are responsible for their payroll and commissions each week. Use the data provided to create a worksheet described below

  Design a program that will allow a user to input a list

Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who lives in Texas

  It industry is becoming increasingly globalized

As you know, the IT industry is becoming increasingly globalized due to outsourcing. Select a country that your industry is likely to outsource to. Using the Internet, find three distinct cultural traits that might affect how you communicate with ..

  Describe how your architecture could be implemented

Read the case study titled "A Patient Infonnation System for Mental Health Care", Describe any shortcomings associated with your chosen architecture pattern for the case study. Describe how your architecture could be implemented in hardware and softw..

  Task manager to recognize and troubleshoot problems

Which system resources are probable to be at root of problem? How can you use system tools, like the Task Manager, to help recognize and troubleshoot these problems?

  The following reflect passing scores in a class versus time

the following reflect passing scores in a class versus time spent weekly preparing for that coursepassc011011011011time

  Analyze the consequences of experiment done on mice

Group that had been fed had retained this ability, but other group had not. Probable reason that scientists used only mice from same pure-bred strain is so that?

  Prepare a gantt chart or project plan

Create a Gantt chart or project plan to record tasks,subtasks, resources and identify the schedule of the project - update the Gantt chart or project plan. -

  How does information technology support supply chains

How does information technology (IT) support supply chains and business processes in the global marketplace?

  Secure encrypted communications

Transmitting personal and business data and information over secure communication channels is critical. In some cases it is required, especially when personally identifiable information is being transmitted. Credit card numbers, Social Security Numbe..

  Where will system administrators create ken users

Currently, system administrators create Ken 7 users in each computer where users need access. In the Active Directory, where will system administrators create Ken 7 users

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