Confused on how to finish this program. C++ Encryption and Decryption using Caesar Cipher and Substitution.

Very lost on the caesar cipher I got the substitution cipher working and close to finishing can anyone help me figure out how to get the caesar cipher working? I've spent 3 hours and can't figure out how to finish this program...
#include<iostream>
#include<vector>
#include<set>
#include<string>

using namespace std;

class Substitution {
int key;
string input;
bool encipher;
public:
//constructor
Substitution(string msg, bool enc) :
input(msg), encipher(enc) {}

//the function for encryption/decryption (Substitution algorithm)
string substitution();
};
class Cipher
{
public:
virtual string encode(string) = 0;
virtual string decode(string) = 0;
};

///////////////////////////////////////////////////////////////////////

//the function for encryption/decryption (Substitution algorithm)
string Substitution::substitution()
{

do {
cout << "Enter key in 1..25>> ";
cin >> key;
cin.ignore();
//fflush(stdin);

if (key > 25 || key < 1)
cout << "KEY ERROR";
//check KEY: if encryption/decryption is possibly

} while (key > 25 || key < 1);


string output = "";


for (int i = 0; i < input.size(); ++i)
{
if (isalpha(input[i])) //if letter
{
//offset='A' for upper letter, offset='a' for lowel letter
char offset = isupper(input[i]) ? 'A' : 'a';

//find shift for current letter for encryption (key) or for decryption (26 - key)
int shift = encipher ? key : 26 - key;

//convert letter (shift letter)
char ch = (char)(((input[i] + shift - offset) % 26) + offset);
output += ch;
}
else
{
//non letter
output += input[i];

}
}

return output;
}

//the function for encryption/decryption (Substitution algorithm)
// Encryption


int main() {
/*
Encrypt a string entered by the user
Choose between two different encryption methods
Decrypt a string entered by the user
Choose between two different decryptions methods
Decrypt without knowing the encryption method (provide all possible outputs)
*/

string source = "";
int option;


do {

cout << "\nEnter the text>> " << flush;
getline(cin, source);
cin.ignore(256, '\n');



cout << "Make your choice" << endl;
cout << "\t1. Substitution cipher, encrypt" << endl;
cout << "\t2. Substitution cipher, decrypt" << endl;
cout << "\t3. Transposition cipher, encrypt" << endl;
cout << "\t4. Transposition cipher, decrypt" << endl;
cout << "\t5. Decrypt without knowing the encryption method (provide all possible outputs)" << endl;
cout << "\t6. Exit" << endl;
cout << ">> ";
cin >> option;
cin.ignore();


string result;

switch (option) {
case 1: {
Substitution s(source, true);
result = s.substitution();
cout << endl << "The encryption string:\n" << result << "\n";
break;
}
case 2: {
Substitution s(source, false);
result = s.substitution();
cout << endl << "The decryption string:\n" << result << "\n";
break;
}
case 3: {
Substitution t(source, true);
result = t.substitution();
cout << endl << "The decryption string:\n" << result << "\n";
break;
}
case 4: {
Substitution t(source, false);
result = t.substitution();

cout << endl << "The decryption string:\n" << result << "\n";
break;
}

case 5: {
Substitution t(source, false);
result = t.substitution();
cout << endl << "The decryption (Caesar Cipher) string:\n" << result << "\n";

Substitution s(source, false);
result = s.substitution();
cout << endl << "The decryption (substitution) string:\n" << result << "\n";
break;
}

case 6:
cout << endl << "Goodbye!" << endl;
break;
}
} while (option != 6);

return 0;
}
Please add code tags to your post.
https://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.