Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool matching_Cases(string user_inputValue[])
- {
- //An array indicating which attribute is open
- bool attributesGate[numbersOf_Attributes];
- //Total number of attribute used
- int gatesOpened = 0;
- //Local array for storing input
- string inputValue_string[numbersOf_Attributes];
- /*
- "Employee Name", "Country", "Designation", "Gender", "Level of Education",
- "Employee ID", "Date Of Birth", "Height", "Weight", "Years of working",
- "Basic Salary", "Allowances"
- */
- //Detecting which attribute is open
- for (int h = 0; h < numbersOf_Attributes; h++)
- {
- if (user_inputValue[h].length() == 0)
- {
- attributesGate[h] = false;
- }
- else
- {
- attributesGate[h] = true;
- }
- }
- //Counting the total attribute opened
- //And put the user input array into a local array variable
- for (int g = 0; g < numbersOf_Attributes; g++)
- {
- if (attributesGate[g] == true)
- {
- gatesOpened++;
- inputValue_string[g] = user_inputValue[g];
- }
- }
- cout << "Gates Opened: " << gatesOpened << endl;
- /////////////////////////////////////////////////
- if (gatesOpened == 0)
- {
- return false;
- }
- /////////////////////////////////////////////////
- for (int a = 0; a < numbersOf_Attributes; a++)
- {
- for (int b = 0; b < THE_ARRAY_SIZE; b++)
- {
- valid_ResultsNo[a][b] = -1;
- }
- }
- for (int p = 0; p < numbersOf_Attributes; p++)
- {
- no_gatesOpened[p] = -1;
- }
- //Opened Gates -= 1
- //Amount to compare is = (n-1) where n is total number of attribute opened
- int compare_Times = (gatesOpened - 1);
- for (int a = 0; a < numbersOf_Attributes; a++)
- {
- for (int b = 0; b < THE_ARRAY_SIZE; b++)
- {
- final_ResultsNo[a][b] = -1;
- }
- }
- //Flags and locators
- int counter_2 = 0;
- int temp_store = 0;
- int validCounts = 0;
- //Assigning ID to no_gatesOpened
- for (int d = 0; d < numbersOf_Attributes; d++)
- {
- if (attributesGate[d] == true)
- {
- no_gatesOpened[counter_2] = d;
- counter_2++;
- }
- }
- //test no gatesOpened///////////////////////////////
- int temp_nogate[12];
- for (int h0 = 0; h0 < 12; h0++)
- {
- temp_nogate[h0] = -1;
- }
- counter_2 = 0;
- for (int h = 0; h < numbersOf_Attributes; h++)
- {
- if (no_gatesOpened[h] != -1)
- {
- temp_nogate[counter_2] = no_gatesOpened[h];
- counter_2++;
- }
- }
- for (int h2 = 0; h2 < numbersOf_Attributes; h2++)
- {
- no_gatesOpened[h2] = temp_nogate[h2];
- }
- ////////////////////////////////////////////////////
- //Assigning IDs to inputValue_string
- for (int f = 0; f < numbersOf_Attributes; f++)
- {
- counter_2 = 0;
- if (attributesGate[f] == true)
- {
- for (int t = 0; t < THE_ARRAY_SIZE; t++)
- {
- temp_store = advancedCompare(inputValue_string[f], f, t);
- if (temp_store == t)
- {
- valid_ResultsNo[f][counter_2] = temp_store;
- counter_2++;
- }
- }
- if (counter_2 != 0)
- {
- validCounts++;
- }
- }
- }
- //////////////////////////////////////////////////
- cout << "How many valid: " << validCounts << endl;
- if (validCounts != gatesOpened && gatesOpened > 1)
- {
- return false;
- }
- //////////////////////////////////////////////////
- int search_result_count = 0;
- if (gatesOpened > 1)
- {
- for (int s = 0; s < compare_Times; s++)
- {
- counter_2 = 0;
- if (s == 0)
- {
- for (int i = 0; i < THE_ARRAY_SIZE; i++)
- {
- for (int j = 0; j < THE_ARRAY_SIZE; j++)
- {
- if (valid_ResultsNo[no_gatesOpened[s + 1]][i] == valid_ResultsNo[no_gatesOpened[s]][j])
- {
- if (valid_ResultsNo[no_gatesOpened[s]][j] != -1)
- {
- final_ResultsNo[s][counter_2] = valid_ResultsNo[no_gatesOpened[s]][j];
- counter_2++;
- }
- }
- }
- }
- }
- else
- {
- for (int a = 0; a < THE_ARRAY_SIZE; a++)
- {
- for (int b = 0; b < THE_ARRAY_SIZE; b++)
- {
- if (valid_ResultsNo[no_gatesOpened[s + 1]][a] == final_ResultsNo[s - 1][b])
- {
- if (final_ResultsNo[s - 1][b] != -1)
- {
- final_ResultsNo[s][counter_2] = valid_ResultsNo[no_gatesOpened[s + 1]][a];
- counter_2++;
- }
- }
- }
- }
- }
- }
- counter_2 = 1;
- for (int p = 0; p < THE_ARRAY_SIZE; p++)
- {
- if (final_ResultsNo[compare_Times - 1][p] != -1)
- {
- search_result_count++;
- }
- }
- if (search_result_count > 0)
- {
- cout << "--------------------------------1+------------------------------------" << endl;
- for (int p = 0; p < THE_ARRAY_SIZE; p++)
- {
- if (final_ResultsNo[compare_Times - 1][p] != -1)
- {
- cout << counter_2 << ". ";
- cout << col1[final_ResultsNo[compare_Times - 1][p]] << " " << STR1[final_ResultsNo[compare_Times - 1][p]] << endl;
- counter_2++;
- }
- }
- cout << "--------------------------------1+------------------------------------" << endl;
- }
- }
- else
- {
- counter_2 = 1;
- for (int p = 0; p < THE_ARRAY_SIZE; p++)
- {
- if (valid_ResultsNo[no_gatesOpened[0]][p] != -1)
- {
- search_result_count++;
- }
- }
- if (search_result_count > 0)
- {
- cout << "---------------------------------1-----------------------------------" << endl;
- for (int p = 0; p < THE_ARRAY_SIZE; p++)
- {
- if (valid_ResultsNo[no_gatesOpened[0]][p] != -1)
- {
- cout << counter_2 << ". ";
- cout << col1[valid_ResultsNo[no_gatesOpened[0]][p]] << " " << STR1[valid_ResultsNo[no_gatesOpened[0]][p]] << endl;
- counter_2++;
- }
- }
- cout << "---------------------------------1-----------------------------------" << endl;
- }
- }
- cout << "Matched Employee(s): " << search_result_count << endl;
- if (search_result_count == 0)
- {
- cout << "---------------------------------0-----------------------------------" << endl;
- cout << endl
- << endl
- << endl
- << endl
- << endl;
- cout << "No Employee(s) Found!" << endl;
- cout << endl
- << endl
- << endl
- << endl
- << endl;
- cout << "---------------------------------0-----------------------------------" << endl;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement