// Ch. 13 Demo Program #3
// Mr. Minich
// purpose - to illustrate an apstring class method that encrypts
//              an apstring by changing each character to the next
//              character in the ASCII table alternately using an accessor
// and a modifier member function.

#include <iostream.h>
#include "apstring.h" // modified to include the encryptAccessor & encryptModifier // member functions int main() { apstring stringToEncrypt("alpha"); // user input that will be encrypted cout << "Enter a string to encrypt: \t"; cin >> stringToEncrypt; cout << "The encrypted string is: \t"; stringToEncrypt.encryptAccessor(); cout << "\nThe original string is still: \t" << stringToEncrypt << endl; cout << "The encrypted string is: \t" << stringToEncrypt.encryptModifier() << endl; cout << "The original string is now: \t" << stringToEncrypt << endl << endl; return 0; }// end of main

THE TWO ADDITIONAL METHODS THAT HAVE BEEN ADDED TO THE APSTRING CLASS IMPLEMENTATION
(APSTRING.CPP FILE)

const apstring & apstring::encryptModifier()
// postcondition: each character is changed to the next character
//   in the ASCII Table
{
	for (int i = 0; i < myLength; i++)
	{
		myCstring[i]++;
	}// end of for

	return *this;
}// end of encryptModifier

void apstring::encryptAccessor()
// postcondition: no change to the apstring object
{
	for (int i = 0; i < myLength; i++)
	{
		cout << char (myCstring[i] + 1);
	}// end of for

}// end of encryptAccessor

THIS IS THE ADDITIONAL MEMBER FUNCTION PROTOTYPES THAT HAVE BEEN ADDED TO THE
APSTRING CLASS DEFINITION (APSTRING.H HEADER FILE)

const apstring & encryptModifier();	 // encrypts string
void encryptAccessor();			 // encrypts string