private string Encrypt(EncryptedWord game) { string target; // the word need to be encrypted string targetAfterEncrypted; // the word after encrypted int invalidationWordCount; // the number of invalid word invalidationWordCount = 0; targetAfterEncrypted = ""; target = GetRandomWord(); if (CheckInputLengthValidation(target)) { bool flag = true; for (int i = 0; i < target.Length; i++) { char letter = target[i]; int letterTransferToNum = (int)letter; if (!CheckInputValidation(letterTransferToNum)) { flag = false; } } if (flag) { targetAfterEncrypted = game.StartEncryptWord(target); } else { if (invalidationWordCount < puzzle.Length) { invalidationWordCount++; GetRandomWord(); } else { } } } else { if (invalidationWordCount < puzzle.Length) { invalidationWordCount++; GetRandomWord(); } else { Console.Write("There is no valid word any more!"); } } return(targetAfterEncrypted); }
EncryptedWord game; // game public Driver() { encrytedWord = ""; game = new EncryptedWord(); }