When your encipher loop has found the letter and converted to the enciphered character, it keeps on checking that character. With a shift of one, if finds it again, changes it to the next letter, till it gets all the way to z/Z, and wraps it around to a/A at the end of the loop.
A couple ways you can fix this. One would be a boolean var in addition to the loop counter, something like:
void encipher(const int shift)
{
int length = this->text.length();
bool found = false;
for (int index = 0; index < length; index += 1)
{
found = false;
for (int count = 0; !found && count < 26; count += 1)
{
if (this->text[index] == LOWER_ALPHABET[count])
{
this->text[index] = LOWER_ALPHABET[(count + shift) % 26];
found = true;
}
else if (this->text[index] == UPPER_ALPHABET[count])
{
this->text[index] = UPPER_ALPHABET[(count + shift) % 26];
found = true;
}
}
}
}
Another would be to use break statements when the conversion is done
for (int count = 0; count < 26; count += 1)
{
if (this->text[index] == LOWER_ALPHABET[count])
{
this->text[index] = LOWER_ALPHABET[(count + shift) % 26];
break;
}
else if (this->text[index] == UPPER_ALPHABET[count])
{
this->text[index] = UPPER_ALPHABET[(count + shift) % 26];
break;
}
} The break gets you out of the inner loop, but the outer loop will execute its next iteration.