//8.
//----------------------------------------------------------------
//-------- Display orignal and encrypted message information
//----------------------------------------------------------------
private void displayEncryptedMessage(String originalMessage, String encryptedMessage) {
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("Enter Message to be encrypted: ");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println(" Plain Text : " + originalMessage);
}
// 9
//----------------------------------------------------------------
// Encrypted it by substituting the character with the corresponding character in the cipher.
//
//----------------------------------------------------------------
private void encrypt(String cipher){
int letterPosition;
String encryptedMessage = "";
String originalMessage = Keyboard.readInput();
displayEncryptedMessage(String originalMessage, String encryptedMessage);
for (letterPosition=0; letterPosition<originalMessage.length(); letterPosition++){
char replaceCipherLetter = cipher.charAt(letterPosition);
encryptedMessage += replaceCipherLetter;}
System.out.println(" Cipher Text: " + encryptedMessage);
}
我对 Java 真的很陌生,所以您的所有评论都将不胜感激......因为方法 8. 是无效的,它不会返回任何值对吗?如果我想将 8 放入 9 中 displayEncryptedMessage(String originalMessage, String encryptedMessage);
,那是 Id 作为参数放入的吗?为什么我会收到这些错误?
Error: ')' expected
Error: illegal start of expression