Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code I have so far. Can you guys help me make it work? I am stuck on getting the grid to actually

This is the code I have so far. Can you guys help me make it work? I am stuck on getting the grid to actually show after I run it and I am having trouble reading the input file (so pretty much all of it) and I am currently coding on XCODE (Mac). The first 2 photos are my own code and the question is below.

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Problem Description In the game of chess, a game board has a specified number of rows and columns (usually 8 rows and 8 columns.) A "rook" is a chess game piece that can move across any number of columns in a horizontal direction or any number of rows in a vertical direction (but a rook cannot move diagonally in any way.) This is indicated for one rook in the image below, where the green squares represent possible moves for a rook found at row ' 3 ' and column 'e' Note that, as in the above figure, most chess players number the rows from 1-8, while the columns are labelled with letters by most chess players. As coders, we tend to think about these as rows 0 through 7 and columns 0 through 7 instead. In chess, two game pieces (of any type, but we are only concerned about rooks in this assignment) are said to be attacking each other if a single valid move can land one piece in the same square as another game piece. You will be writing a complete C++ program that checks to see if there exists a pair (or more) of two rooks on a given chess board (that only has rook game pieces on it) that are attacking each other. There is one additional component to this problem - several of the squares on the board have "blocks" in them, and a rook cannot move or see past a block. Your program should: 1. prompt for and read in the name of an input file containing the size of a chess board, the locations of rooks, and the locations of blocks as follows: - the first item in the input file will be a (positive) integer representing the number of rows in the chess board. This value will be no larger than 100. - the second item in the input file will be a (positive) integer representing the number of columns in the chess board. This value will be no larger than 100. - What follows will be a sequence of rows, each containing one character for each column. There are three possible values for each character: - '., which means this is am empty chess board square (that does not contain a block or a rook) - '\#', which means this chess board square is a block - ' R, which means this chess board square contains rook 2. Print out the board, as read from the input file, one row at a time. 3. Print out one of two messages, based on the placement of rooks and blocks on the chess board: - "No two rooks can attack each other" should be printed if no two rooks can attack each other. - "At least two rooks can attack each other" should be printed if two or more rooks can attack each other. For example, suppose the file named input1. data contains the following: 57 chess board has 5 rows and 7 columns ..R.\#R. .R. .\#.\# If you ran your program and specified the above input file (with program output in regular text and input in italics 1 ) then the execution would look like: Please enter the name of an input file: input1.data ..R.\#R. .R..\#.\# R# \#.R\#R \#R\#R\#R\# R..\#..R No two rooks can attack each other

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions