#include #include #include #include #include "HiddenSquaresHeader.h" using namespace std; //Extern Int command used to call in global varible to be used in functions from main.cpp extern int hiddensquarex, hiddensquarey; extern int LastGuess[26][26]; extern int lives; //Function for creating the hidden square with random X and Y coordinates int CreateHiddenSquare() { //Begin random number generator srand((unsigned)time(NULL)); //Choose random numbers for x and y coords out of 26 hiddensquarex = rand()%25; hiddensquarey = rand()%25; //Clear the screen system("CLS"); //For testing purposes show X and Y value //cout << hiddensquarex << " " << hiddensquarey; return 0; } //Function for entering coordinates and validation checking : also contains code that displays the //Direction of the hidden square from the last values entered int EnterCoordinates() { //Declare varibles for the coordinates that will be inputted by the user //CheckedColumn is char because the vertical line is alphabetic. int CheckedRow = 0; char CheckedColumn = 0; //Show player how many attempts he has to guess the coordinates of the hidden square. cout << "You have " << lives << " lives remaining" << endl; //Validation code - only lets the user input a value between 1 and 26 while (CheckedRow < 1 || CheckedRow > 26) { cout << "Please Enter which number you would like to check 1 => 26" << endl; cin >> CheckedRow; //Code to ensure correct datatype is entered, there was previously a bug where incorrect datatype would cause and infinite loop. if (cin.fail()) { //If the input was not valid, clear last input and ignore first 1000 characters cin.clear(); cin.ignore(1000,'\n'); } } //Validation code - only lets the user input a value between 65 and 90 (The ascii values of A - Z) while (CheckedColumn < 65 || CheckedColumn > 90) { cout << "Please Enter Which letter you would like to check A => Z (Case Sensitive)" << endl; cin >> CheckedColumn; //Check if input was valid if (cin.fail()) { //If the input was not valid, clear last input and ignore first 1000 characters cin.clear(); cin.ignore(1000,'\n'); } } //Inform the user of the coordinates he has entered cout << "You have checked " << CheckedRow << " " << CheckedColumn << " and the result is..." << endl; // Debug Line // cout << "DEBUG: if(" <