Michael Mohan
This module had 2 projects to help with becoming adept at C and C++. The first project was a program using C that generates a 3 line poem along with title. Each time the application is run, the poem generated will be different. The application can be downloaded here and the source code can be viewed here.
The second project was a C++ program using MFC consisting of a user interface to encrypt and decrypt any message entered. This application used a random number generator to encrypt any string of text entered into the user interface and provided the additional functionality to decrypt it again and display the decrypted text in another dialogue box. The application can be downloaded here and the source code can be viewed here.














Poem Generator
In order to write the program to develop random 3 line poems, a set of dictionaries of words were stored. A set of 15 different nouns, adjectives, verbs, adverbs and prepositions were stored to pick from when constructing the poems. The structure of the poem was then constructed from these different words or phrases. The structure was as follows:
Title: A (adjective) (noun)
Line 1: A (adjective 1) (noun 1) (verb 1) (preposition 1) the (adjective 2) (noun 2).
Line 2: (adverb 1) the (noun 1) (verb 2).
Line 3: The (noun 2) (verb 3) (prep 2) a (adjective 3) (noun 3).
Each time the program is run, the different words and phrases are chosen from their dictionaries at random. For the adjective and noun in the title and the adverb at the beginning of line 2 capitalised words were used. For this, the program the utilised to loop through the dictionaries of adjectives, nouns and adverbs to create capitalised versions of those words.
Text Encryptor
The second project used MFC to store text as an input and then use a cipher code when the encrypt button is pressed to encrypt that text and then output the encrypted version along with the cipher code. If the encrypted text and cipher code is displayed in their corresponding text boxes, the decrypt button can be used to decrypt and output the plain text version of the input. The MFC functionality is used to listen for the button presses and modify and display the inputs in the text boxes accordingly. To encrypt the text, the cipher code is generated first by finding a random number between 0 and 999. This number is then represented as a string with each digit now being represented as an individual character. The encrypted text is set to be the same amount of characters as the original text. Then, for each character of the text, an encrypted character is generated by using the exclusive or operation with that character and one of the characters of the cipher code. Each character of the cipher code is iterated through and if the program gets to the end of the code, it will loop back to the first character and perform the next exclusive or operation using it again. This process will continue until a cipher character is generated to represent each character of the original text. This will then form the encrypted version of the text. This can then be decrypted again by repeated the process of the encrypted text, as long as the cipher code is still displayed in its text box for the program to use. A third button exists in order to close the program.