// Exam2 Lab: Caesar's Cipher (25 pts.)
// due: Apr 12th (2026-04-12), 11:59pm
// submit your file as: username_exam2_L1.cpp
// to: james.dittrich+YSU@gmail.com

// Julius Caesar encoded sercret messages by shifting the alphabet 3 letters,
// so for example:
// "Hello World!"
// becomes:
// "Khoor Zruog!"
// Note this is case-sensitive and ignores non-alphabetic characters (just copy the original).
// Implement this algorithm, but allow for a variable (Integer) amount of letters to shift.
// If you feed the ciphered message with the inverted shift amount (shiftAmount * -1), 
// you can recover the plaintext message.
// You can use the pseudocode and skeleton below, or write your own function...
// but please no INTERNET COPYPASTA!*
// *see "Academic Honesty" in the Syllabus for details.

#include <iostream>
#include <string>
using namespace std;


string encrypt(string plaintext, int shiftAmount){
	// string ciphertext;
	// TODO: Iterate through the plaintext message.
	// TODO: Use the shiftAmount value to determine the ciphertext character.
	// TODO: Build the ciphertext string by concatenation.
	return ciphertext;
}

// TODO: create another function "decrypt"
// to invert the process for decryption back into clear text.
// There is a very simple way to do this.

string decrypt(string ciphertext, int shiftAmount){
	// TODO: your code here (HINT: be smart and LAZY, think about how to reuse the above!)
	return plaintext;
}


int main(){
	int shiftAmount;
	string plaintext, ciphertext;

	cout << "Enter the number of characters to shift (-25 to 25): " << endl;
	// plus or minus 26 is the same message. Anything farther than that mod 26 
	// will result in the same shift amount. 
	cin >> shiftAmount;
	// test that the shift amount falls into this range, or adjust the value (your choice), 
	// re-prompt if necessary (input validation).

	cout << "Enter the message plaintext: " << endl;
	getline(cin,plaintext);

	// note that whitespace, numerals, symbol characters, and punctuation 
	// (all non-alphabetical characters) DO NOT get shifted.
	// HINT: you can test each character by their values in the ASCII lower and uppercase ranges.
	// See the capitalization and ASCII table examples.

	// PSEUDOCODE:
	// iterate through each of the letters in the message and build the ciphertext string by 
	// concatenating one character at a time.
	// the simplest way to concatenate is to just use the overloaded '+=' operator on a string, 
	// for example (comment these out):
	string puppy = "do";
	puppy += "g";
	// the variable puppy now holds "dog" because the 'g' got tacked on the end.
	cout << "\nHey, here's a dog: " << puppy << endl; 

	// PSEUDOCODE (HINT: Think about Blackjack "for each card in the player's hand")
		// check to see if the letter is in the range of lowercase letters (abcdefghijklmnopqrstuvwxyz)
			// 1. convert the letter to a number
			// 2. shift the number by the shift value
			// 3. if you go past z, wrap back around the alphabet, e.g., x+3=a, y+3=b, z+3=c.  There's a simple operation to do this!
			// 4. if you shift in the negative direction and are before 'a', wrap back around in the other direction, e.g., a-3=x, b-3=y
			// 5. change the number back into a character and concatenate the current character (as a string) onto the ciphertext string.
		// check to see if the letter is in the range of uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
			//follow the same steps as above, wrapping around where approriate.
		// when it's not in any of those ranges, leave the character alone and add it to the ciphertext, unaltered.

	// print out the ciphertext
	cout << "The ciphertext message is: " << ciphertext << endl;

	return 0;
}
