Last active
October 9, 2018 17:19
-
-
Save janell-baxter/650c9e7b50fe760ef7d07f9b80b407e7 to your computer and use it in GitHub Desktop.
Example framework for string manipulation example (simple substitution cipher). Introduction to Programming, Summer 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
namespace Cipher | |
{ | |
class Cipher | |
{ | |
string alphabet; | |
string substitute; | |
public Cipher() | |
{ | |
alphabet = "abcdefghijklmnopqrstuvwxyz"; | |
substitute = "opdefghiqrsxyzabcjklmntuvw"; | |
} | |
public string Encrypt(string _message) | |
{ | |
int index; | |
char replacement = 'z'; | |
string result = ""; | |
_message = _message.ToLower(); | |
foreach (char c in _message) | |
{ | |
//add code here to replace each character c | |
//with the letter from the same index number in the substitute string | |
} | |
return result; | |
} | |
public string Decrypt(string _message) | |
{ | |
string result = ""; | |
return result; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using static System.Console; | |
namespace Cipher | |
{ | |
class Message | |
{ | |
public Message() | |
{ | |
WriteLine("Hello agent."); | |
Run(); | |
} | |
private void Run() | |
{ | |
Cipher cipher = new Cipher(); | |
string message; | |
Clear(); | |
Write("Enter text: "); | |
message = ReadLine(); | |
WriteLine(cipher.Encrypt(message)); | |
WriteLine("Press any key to continue..."); | |
ReadKey(); | |
Run(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Cipher | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.Title = "Manipulating String Example: Simple Cipher"; | |
Message message = new Message(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment