Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IrmaMoves.h : #include IrmaMoves.h typedef struct Move { Irma irma; // an instance of Irma L Location from_loc; // location where Irma is moving from

IrmaMoves.h :

#include "IrmaMoves.h"

typedef struct Move {

Irma irma; // an instance of Irma

L Location from_loc; // location where Irma is moving from

Location current_loc; // location where Irma is passing over

Location to_loc; // location where Irma is moving to

} Move;

typedef struct Location {

char col; // the square's column ('a' through 'h')

int row; // the square's row (0 through 7)

} Location;

typedef struct Irma {

int ws; // wind speed (MPH)

int wg; // wind gusts (MPH)

} Irma;

IrmaMoves.c:

#include #include #include #include "IrmaMoves.h"

char **createMapBoard(void){ char **board = malloc(8*sizeof(char *)); //dynamically allocate memory for rows for(int i = 0 ; i < 8 ; i++) //dynamically allocate memory for indiviual elements board[i] = malloc( 8*sizeof(char) ); board[0][0] = 'F'; //initialize the array with the map layout board[0][1] = 'F'; board[0][2] = ' '; board[0][3] = ' '; board[0][4] = ' '; board[0][5] = ' '; board[0][6] = ' '; board[0][7] = ' '; board[1][0] = ' '; board[1][1] = 'F'; board[1][2] = ' '; board[1][3] = ' '; board[1][4] = ' '; board[1][5] = ' '; board[1][6] = ' '; board[1][7] = ' '; board[2][0] = ' '; board[2][1] = 'F'; board[2][2] = 'F'; board[2][3] = ' '; board[2][4] = ' '; board[2][5] = ' '; board[2][6] = ' '; board[2][7] = ' '; board[3][0] = ' '; board[3][1] = ' '; board[3][2] = 'F'; board[3][3] = ' '; board[3][4] = ' '; board[3][5] = ' '; board[3][6] = ' '; board[3][7] = ' '; board[4][0] = ' '; board[4][1] = ' '; board[4][2] = 'K'; board[4][3] = ' '; board[4][4] = ' '; board[4][5] = ' '; board[4][6] = ' '; board[4][7] = ' '; board[5][0] = 'C'; board[5][1] = ' '; board[5][2] = ' '; board[5][3] = 'B'; board[5][4] = ' '; board[5][5] = ' '; board[5][6] = ' '; board[5][7] = ' '; board[6][0] = ' '; board[6][1] = 'C'; board[6][2] = 'C'; board[6][3] = ' '; board[6][4] = 'D'; board[6][5] = ' '; board[6][6] = ' '; board[6][7] = ' '; board[7][0] = ' '; board[7][1] = ' '; board[7][2] = 'C'; board[7][3] = ' '; board[7][4] = ' '; board[7][5] = 'D'; board[7][6] = 'D'; board[7][7] = ' '; return board; };

char **destroyMapBoard(char **board){ //frees up the memory allocated to the board free(board); return NULL; };

void printMapBoard(char **board){ //printing the map in the specified format printf("======== "); for (int i = 0; i < 8; i++){ for (int j = 0; j < 8; j++){ printf("%c",board[i][j]);} printf(" ");} printf("========"); printf(" "); printf(" "); };

Please help with this Function everytime I ask a question the answers simply restate the Information provided above without helping with the question below:

char **predictIrmaChange (char* str, Move *irmaMove); Description: This function should start by printing the map board with Irma in its starting position, using the arrangement described in Appendix A: Irma Movement and the specific format shown in the test case output files included with this assignment. (You will want to call createMapBoard() from within this function to create a 2D char array to represent the map board, and then call the printMapBoard() function to print it to the screen. See above for the descriptions of both of those functions.) After printing the initial map board, this function should parse all of the algebraic notation strings passed in through making calls to the parseNotationString() function (described below). The printMapBoard() function is called once after the Irmas location has been identified, and another time after the boards final configuration has been processed. Note that this function should print the resulting board (again, with a line of eight equal signs above and below the board each time, always followed by a blank line). In addition, updating Irmas wind speed/gusts and checking Irma directions should be ======== FF F FF F K C B CC D C DD ======== Note: This is a completely blank line. (No spaces.) implemented in this function as described in Appendix A: Irma Movement. Output: This should print out the map board in the manner described above, with precisely the same format shown in the test case output files included with this assignment. Return Value: A pointer to the dynamically allocated 2D array (i.e., the base address of the 2D array), or NULL if any calls to malloc() fail. void parseNotationString(char* str, Move* irmaMove); Description: This function receives an algebraic notation string, str, and one Move struct pointer. The function must parse str and extract information about Irma moves encoded there, and populate all corresponding fields in the struct pointed to by irmaMove. At the very least, it will always be possible to set the from_loc, current_loc, to_loc, and irma.ws, irma.wg fields in Irma struct. It is necessary to denote which column and/or row the Irmas move is coming from, and also the column and/or row in a moves to_loc field which determine where Irma ends. To initialize from_loc, current_loc, to_loc fields, you must initialize that moves from/current/to_loc.col fields to x to indicate that the column is currently unknown. Similarly, the moves from/current/to_loc.row coordinate must be initialized to -1. After initialization, update from_loc, current_loc, to_loc, and irma.ws, irma.wg fields through extracting information from given algebraic notation string. Output: This function should not print anything to the screen. Return Value: There is no return value. This is a void function.

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What is a verb?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago