Question: my code encodes and decodes like this Test VigenereForwardIterator First phrase: To be , or not to be: that is the question: Encoded text:
my code encodes and decodes like this
Test VigenereForwardIterator
First phrase: To be or not to be: that is the question:"
Encoded text: Lt nf ia ccm lt nf: nqph bk ytf kdtgmatz"
Decoded text: To be or not to be: that is the question"
Second phrase: Be cool"
when i need it to do this
Test VigenereForwardIterator
First phrase: To be or not to be: that is the question:"
Encoded text: Lt nf ia ccm lt nf: nqph bk ytf kdtgmatz:"
Decoded text: To be or not to be: that is the question:"
Second phrase: Be cool"
Encoded text: Tj opiu"
Decoded text: Be cool"
Third phrase:
Encoded text:
Decoded text: done
and also YOU ARE NOT ALLOWED TO CHANGE THE P AT ALL, ONLY THE VIGERENEFORWARDITERATOR.CPP
VIGERENEFORWARDITERATOR.CPP
void VigenereForwardIterator::encodeCurrentChar noexcept
if fKeys fKeys.end
char messageChar fSourcefIndex;
if std::isalphamessageChar
char keywordChar fKeys;
if std::isalphakeywordCharstd::isupperkeywordChar
fCurrentChar messageChar;
return;
sizet row staticcastkeywordChar A;
if row CHARACTERS
fCurrentChar ;
return;
sizet column staticcaststd::touppermessageCharA;
char encodedChar fMappingTablerowcolumn;
if std::islowermessageChar
encodedChar std::tolowerencodedChar;
fCurrentChar encodedChar;
fKeys;
else
fCurrentChar messageChar;
void VigenereForwardIterator::decodeCurrentChar noexcept
if fKeys fKeys.end
char messageChar fSourcefIndex;
if std::isalphamessageChar
char keywordChar fKeys;
if std::isalphakeywordCharstd::isupperkeywordChar
fCurrentChar messageChar;
return;
sizet row staticcastkeywordChar A;
sizet column ;
while column CHARACTERS && fMappingTablerowcolumn std::touppermessageChar
column;
if column CHARACTERS
int decodedCharInt A staticcastcolumn;
char decodedChar staticcastdecodedCharInt;
if std::islowermessageChar
decodedChar std::tolowerdecodedChar;
fCurrentChar decodedChar;
fKeys;
else
fCurrentChar messageChar;
else
fCurrentChar messageChar;
P that is in my main, do not edit
#ifdef P
void runP
gCount;
std::cout "Test VigenereForwardIterator" std::endl;
std::string lKey "Relations";
std::string lPhraseTo be or not to be: that is the question:";
std::cout "First phrase: lPhrase std::endl;
std::string lEncoded;
VigenereForwardIterator iterlKey lPhrase;
for ; iter iterend; iter
lEncodediter;
std::cout "Encoded text: lEncoded std::endl;
std::string lDecoded;
VigenereForwardIterator iterlKey lEncoded EVigenereMode::Decode;
for ; iter iterend; iter
lDecodediter;
std::cout "Decoded text: lDecoded std::endl;
std::string lPhraseBe cool";
std::cout "Second phrase: lPhrase std::endl;
std::string lEncoded;
for char c : VigenereForwardIteratorlKey lPhrase
lEncoded c;
std::cout "Encoded text: lEncoded std::endl;
std::string lDecoded;
for char c : VigenereForwardIteratorlKey lEncoded EVigenereMode::Decode
lDecoded c;
std::cout "Decoded text: lDecoded std::endl;
std::string lPhrase;
std::cout "Third phrase: lPhrase std::endl;
std::string lEncoded;
for char c : VigenereForwardIteratorlKey lPhrase
lEncoded c;
std::cout "Encoded text: lEncoded std::endl;
std::string lDecoded;
for char c : VigenereForwardIteratorlKey lEncoded EVigenereMode::Decode
lDecoded c;
std::cout "Decoded text: lDecoded std::endl;
std::cout "done" std::endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
