Menu

[Solved]Create C Module Called Chesspiece Defines Structured Type Named Chesspiece Associated Func Q37180115

Create a C++ module called ChessPiece that defines a structuredtype named ChessPiece and associated functions. Give the completecontents of the ChessPiece.h file. Show any lines needed to protectthe file against being included multiple times in a program. Showany lines needed to include libraries.

The ChessPiece type has fields for: colour (either “black” or”white”), name (e.g., “king”), row (from 0 to 7), and column (from0 to 7). Choose the most appropriate type for each field.

Give prototypes for three functions that operate on values ofthe ChessPiece type. Each function takes aChessPiece as its firstparameter; this parameter should be passed efficientlyand, if appropriate, guaranteed not to change. The three functionsare as follows:

  • initChessPiece takes four additional parameters giving thevalues for the colour, name, row, and column that should beinitialized in the chess piece and returns nothing.
  • getStringColourChessPiece takes no other parameters and returnsa string containing the colour of the chess piece (either “black”or “white”) centered in a string 6 characters long. If there is anodd number of letters, put it to the left of center.
  • getStringNameChessPiece takes no other parameters and returns astring containing the name of the chess piece (e.g., “king”)centered in a string 6 characters wide. If there is an odd numberof letters, put it to the left of center.

(b) Give the top portion of thecontents of the ChessPiece.cpp file plus the implementation of theinitChessPiece function. The implementations of the other functionsare not required.

Expert Answer


Answer to Create a C++ module called ChessPiece that defines a structured type named ChessPiece and associated functions. Give th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *