C++ programming create a class codeMaker to encode and decode secret message. with Linear search

preview_player
Показать описание
store them in a one-dimensional array of characters, using the ASCII code of the original character, minus 32, as the index for the stored substitution character. So, for example, the substitution for ASCII character 32, a blank, will be stored in array element 0. The substitution for ASCII character 33, an exclamation point, will be in array element 1, and so forth. The code will be hard to break because even the blank space will be represented by another
character. So someone trying to read the code will not know where one word ends and the next one begins. When the encode method is called, it is passed a string holding the message to be encoded. The method simply uses the ASCII code of each character in the string to compute the
array index where its replacement character is located. Once each character in the string has been replaced, the string is returned.



When the decode method is called, it is passed a string holding an encoded message to be
turned back into its original, or plain text, form. However, this method cannot compute an
index to reverse the code. Instead, for each character in the string, it must do a search of the array to locate it. When the character is found, its array subscript can be used to compute the ASCII value of the original character. Once each character in the encoded string has been translated back to its original form, the string is returned. In addition to creating the CodeMaker class, we will also write a client program that does the following:
• Creates a CodeMaker object.
• Has the user input a message and store it as a string.
• Calls the encode function, passing it the string.
• Displays the returned encoded string.
• Calls the decode function, passing it the encoded string.
• Displays the returned decoded string. This should equal the original message.
Рекомендации по теме
join shbcf.ru