PROGRAM DESCRIPTION: For this C++ program, you will edit your Homework 5 program
ID: 3571530 • Letter: P
Question
PROGRAM DESCRIPTION: For this C++ program, you will edit your Homework 5 programming assignment to add functionality to play a very simplified version of the "Candy Crush game called "1030 Crush" where the goal is to match an existing combination of three or more characters on the board to gain points in a finite number of moves. Unless so indicated, all of the requirements in Homework 5 also hold for Homework 6. Note that there are some changes to the requirements! You will take your solution from Homework 5, and edit it as follows 1. You shall organize your program into three files prgm.h will hold the include directives for the necessary libraries, any permitted global constants, any enumerated data types, any type definitions, any structure definitions, and the list of function prototypes e., function declarations). main .cpp will hold the local include directive for the header file as well as the main function for the program func .cpp will hold the local include directive for the header file as well as all function definitions (not including main, of course) used in the program. 2. Define a global structure (i.e., a struct) that contains the following members. (1) a character member that holds the row position on the board note that this character may be a single character in the range A 'I', or "R (2) an integer member that holds the column position on the board -note that this integer has a range 0-9, (3) a character member that holds the direction of the match -note that this character may be either the single character V. for vertical, or "H, for horizontal: (4) an integer member that keeps track of the number of moves used in the game; and (5) an integer member that keeps track of the score for the game 3. In addition to the global struct and enumerated data type, you may also use global constants for any type definitions, the size of the board, the number of enum values (i e., 6), and the maximum number of moves in a game (i.e., 10) 4. Instead of a traditional two-dimensional array as was done in Homework 5, you will declare and create a two-dimensional dynamic array in main to represent the 9-by-9 board for the enum type you declared to represent the various values that a position may assume. Since the board array is not global, you will pass the board array to the needed functions as a pointer (actually, as a pointer to a pointer). You will need to make sure to return the memory for the two- dimensional array back to the freestore when your program is done using it (at the end) 5. Inside main you will add a loop to play the game until the user has exhausted the maximum number of moves, i this case, 12.Explanation / Answer
#include #include #include #include #define ROW 10 #define COL 10 int x,y; int main() { int r=1; int arr[ROW][COL]; char name[20]; printf("-------NUMBER CRUSH------- *************************** "); printf("Enter your name: "); scanf("%c", &name); system("cls"); r=1; while(r=1) { printf("-------NUMBER CRUSH------- *************************** "); printf("Welcome %c, LET'S PLAY!! ", name); initialize(arr); printf(" "); printf("to regenerate the array press 1: "); scanf("%i", &r); system("cls"); } return 0; } /*define grid and populate with random numbers and print to screen*/ int initialize(int grid[ROW][COL]) { int n; srand(time(NULL)); for(x=0;xRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.