Question: C++ ******************************************************************************************************************************************************** 1) Create a class called EncryptedString that stores a string in an encrypted format, then write a small driver program to test your
C++
********************************************************************************************************************************************************
1) Create a class called EncryptedString that stores a string in an encrypted format, then write a small driver program to test your class.) Class Members Your class should only have one private data field of type string. This variable will store a string in encrypted format. Do not store any other data in your EncryptedString object.
2) Your class should have the following public methods (member functions):
3) A default (no argument) constructor that stores an empty string in the data field. 4) A constructor that takes a string as a parameter and stores the encrypted version of the parameter in the data field. This method should not actually do any "work". It should call the set method to encrypt and store the string. 5) A method called set that takes a string as a parameter. It should encrypt the string parameter and store the result in the object. See the Encryption Algorithm section below. Important: This method should discard any illegal characters in the string parameter. Remember that only alphabetic characters (upper and lower case letters A through Z) and the space (blank) character are allowed in an EncryptedString. The easiest way to remove any illegal characters is to start with an empty string. Then add characters as you encrypt them, leaving out the illegal characters. Important: Removing a character from a string should make the string shorter. Just replacing a character with a space is not the same as removing it. A method called get that returns a decrypted version of the string that is stored in the object. The returned value should be the same as the original string that was stored but with any illegal characters removed. This method should not change the encrypted string stored in the object. 6) Your method prototypes should be:
EncryptedString(); EncryptedString( string str ); void set( string str ); string get(); Notice that inside an EncryptedString object, only the encrypted version of a string is stored. Code outside the class will only see "normal" (unencrypted) strings. Each EncryptedString object is responsible for encrypting the string to be stored and decrypting the string before it is returned.
Normally, you would want to prevent code from outside the class from "seeing" the encrypted version of the string. However, for debugging add one more public method to your class:
A method called getEncrypted that returns the string in encrypted format. This method should not change the encrypted string stored in the object. The method prototype should be: string getEncrypted(); Use a constant method, make get() and getEncrypted().
7) Encryption algorithm
The space character is not encrypted. A space is stored as a space. An alphabetic character is replaced by its predecessor in the ASCII code sequence. For example, the predecessor of C (ASCII code 67) is B (ASCII code 66). Exceptions: For encryption purposes, the predecessor of A is Z, and the predecessor of a is z. For example, the string Hi Mom! would be encrypted as Gh Lnl. 8) Decryption algorithm
The space character is not decrypted. A space is stored as a space. An alphabetic character is replaced by its successor in the ASCII code sequence. For example, the successor of C (ASCII code 67) is D (ASCII code 68). Exceptions: For decryption purposes, the successor of Z is A, and the successor of z is a. USE constants like 'A' makes your code much easier to read (as opposed to use ASCII codes like 65).
Driver 9) Write a small driver program to test your class. Your program should exercise every class method and display enough information and make sure class is working correctly.
Requirements:
*3 splits files: *Test program, *a class header file (class definition with data member definitions and method prototypes only), * class implementation file containing class method definitions. ********************************************************************************************************************
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
