I having trouble with my code this the issue "executeCmd check undo command (0/2), and  executeCmd check number of correctly flagged mines (0/2)". This is the code I give you  void initField(int num_of_mine) {   c00 = c01 = c02 = c03 = c04 =    c10 = c11 = c12 = c13 = c14 =   c20 = c21 = c22 = c23 = c24 =   c30 = c31 = c32 = c33 = c34 =   c40 = c41 = c42 = c43 = c44 =   c50 = c51 = c52 = c53 = c54 =   c60 = c61 = c62 = c63 = c64 =   c70 = c71 = c72 = c73 = c74 = UNKNOWN;   setMine(num_of_mine); } bool isMine(int i, int j) {   int cell = getCell(i, j);   return cell == UNFLAGGED_MINE || cell == FLAGGED_MINE; } void reveal(int i,int j) {   if (isMine(i, j)) {       explode = true;   } else {       int mineCount = 0;       for (int di = -1; di <= 1; di++) {           for (int dj = -1; dj <= 1; dj++) {               if (di == 0 && dj == 0) continue;               int ni = i + di, nj = j + dj;               if (ni >= 0 && ni < height && nj >= 0 && nj < width) {                   if (isMine(ni, nj)) mineCount++;               }           }       }       setCell(i, j, mineCount);   } } void executeCmd(char action, int row, int col) {     switch (action) {         case 'f': // Flagging or unflagging a cell             if (getCell(row, col) == UNKNOWN) {                 if (isMine(row, col)) {                     setCell(row, col, FLAGGED_MINE);                     num_correct_flagged_mine++;                 } else {                     setCell(row, col, INCORRECT_FLAGGED_MINE);                     num_incorrect_flagged_mine++;                 }             } else if (getCell(row, col) == FLAGGED_MINE) {                 setCell(row, col, UNKNOWN);                 num_correct_flagged_mine--;             } else if (getCell(row, col) == INCORRECT_FLAGGED_MINE) {                 setCell(row, col, UNKNOWN);                 num_incorrect_flagged_mine--;             }             break;         case 'r':             reveal(row, col);             break;         case 'u':             if (getCell(row, col) == FLAGGED_MINE) {                 setCell(row, col, UNKNOWN);                 num_correct_flagged_mine--;             } else if (getCell(row, col) == INCORRECT_FLAGGED_MINE) {                 setCell(row, col, UNKNOWN);                 num_incorrect_flagged_mine--;             }             break;     } } can you help what the problem part of my code

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I having trouble with my code this the issue "executeCmd check undo command (0/2), and  executeCmd check number of correctly flagged mines (0/2)". This is the code I give you 

void initField(int num_of_mine) {
  c00 = c01 = c02 = c03 = c04 = 
  c10 = c11 = c12 = c13 = c14 =
  c20 = c21 = c22 = c23 = c24 =
  c30 = c31 = c32 = c33 = c34 =
  c40 = c41 = c42 = c43 = c44 =
  c50 = c51 = c52 = c53 = c54 =
  c60 = c61 = c62 = c63 = c64 =
  c70 = c71 = c72 = c73 = c74 = UNKNOWN;

  setMine(num_of_mine);
}

bool isMine(int i, int j) {
  int cell = getCell(i, j);
  return cell == UNFLAGGED_MINE || cell == FLAGGED_MINE;
}

void reveal(int i,int j) {
  if (isMine(i, j)) {
      explode = true;
  } else {
      int mineCount = 0;
      for (int di = -1; di <= 1; di++) {
          for (int dj = -1; dj <= 1; dj++) {
              if (di == 0 && dj == 0) continue;
              int ni = i + di, nj = j + dj;
              if (ni >= 0 && ni < height && nj >= 0 && nj < width) {
                  if (isMine(ni, nj)) mineCount++;
              }
          }
      }
      setCell(i, j, mineCount);
  }
}

void executeCmd(char action, int row, int col) {
    switch (action) {
        case 'f': // Flagging or unflagging a cell
            if (getCell(row, col) == UNKNOWN) {
                if (isMine(row, col)) {
                    setCell(row, col, FLAGGED_MINE);
                    num_correct_flagged_mine++;
                } else {
                    setCell(row, col, INCORRECT_FLAGGED_MINE);
                    num_incorrect_flagged_mine++;
                }
            } else if (getCell(row, col) == FLAGGED_MINE) {
                setCell(row, col, UNKNOWN);
                num_correct_flagged_mine--;
            } else if (getCell(row, col) == INCORRECT_FLAGGED_MINE) {
                setCell(row, col, UNKNOWN);
                num_incorrect_flagged_mine--;
            }
            break;
        case 'r':
            reveal(row, col);
            break;
        case 'u':
            if (getCell(row, col) == FLAGGED_MINE) {
                setCell(row, col, UNKNOWN);
                num_correct_flagged_mine--;
            } else if (getCell(row, col) == INCORRECT_FLAGGED_MINE) {
                setCell(row, col, UNKNOWN);
                num_incorrect_flagged_mine--;
            }
            break;
    }
} can you help what the problem part of my code

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education