Question: I dont know what I am doing wrong... it keeps saying that it is skipping things when i run the debug... I am working on

I dont know what I am doing wrong... it keeps saying that it is skipping things when i run the debug... I am working on creating classes and then impliminting them in the main
here is the code I have so far...
int main()
{
int choice =0;
string input;
int offsetInput;
string encoded;
string decoded;
do {
cout <<"[1] Set offset
[2] Encode a message
[3]Decode a message
[4] Exit
"<< endl;
cin >> choice;
switch (choice){
case 1:
cout << "What offset? ";
cin >> offsetInput;
TextCodec(offsetInput);
break;
case 2:
cout << "What message? ";
getline(cin, input);
TextCodec codec;
encoded = codec.Encode(input);
cout << encoded << endl;
break;
case 3:
cout << "What message? ";
cin.ignore();
getline(cin, input);
TextCodec codec;
decoded = codec.Decode(input);
cout << decoded << endl;
break;
case 4:
cout << "Thanks for playing";
break;
}
} while (choice!=4);
};
class TextCodec {
//attributes
short int offset;
public:
//default constructor
TextCodec(){
SetOffset(0);
}
//overload constructor
TextCodec(short int offset){
SetOffset(offset);
}
void SetOffset(short int offset){
this->offset = offset;
}
//encode method
string Encode(string message){
std::string result = message;
for (int i =0; i < message.length(); i++)
{
result[i]=(char)(result[i]+ offset);
}
return result;
}
//decode method
string Decode(string message){
std::string result = message;
for (int i =0; i < message.length(); i++)
{
result[i]=(char)(result[i]- offset);
}
return result;
}
};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!