我需要我的chiper實驗室的幫助。我的指令是:無法讓我的密碼實驗室工作
Write a program that accepts any number of strings as command-line arguments and displays those strings encrypted with the Atbash cipher. You program should be as modular as possible and use good object oriented programming techniques. Your program must be thoroughly documented using javadoc comments.
我有String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
應該編碼字符串,這樣一個將返回Z和B將返回Y和等。我在Eclipse中完成了我的密碼實驗,並且沒有運行。我不確定我做錯了什麼。
public class CaesarCipher {
public static void main(String[] args) {
CaesarCipher cc = new CaesarCipher();
}
public static final int ALPHASIZE = 26;
public static final char [] alpha = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
protected char[] encrypt = new char[ALPHASIZE];
protected char[] decrypt = new char[ALPHASIZE];
public CaesarCipher() {
for (int i=0; i<ALPHASIZE; i++)
encrypt[i] = alpha[(i + 3) % ALPHASIZE];
for (int i=0; i<ALPHASIZE; i++)
decrypt[encrypt[i] - 'A'] = alpha[i];
}
/** Encryption Method */
public String encrypt(String secret) {
char[] mess = secret.toCharArray();
for (int i=0; i<mess.length; i++)
if (Character.isUpperCase(mess[i]))
mess[i] = encrypt[mess[i] - 'A'];
return new String(mess);
}
/** Decryption Method */
public String decrypt(String secret) {
char[] mess = secret.toCharArray();
for (int i=0; i<mess.length; i++)
if (Character.isUpperCase(mess[i]))
mess[i] = decrypt[mess[i] - 'A'];
return new String(mess);
}
}
我假設這裏沒關係? – arshajii
它會幫助,如果你告訴我們當你決定運行你的程序會發生什麼 –
這是我在eclipse中運行時給我的東西......線程「main」中的異常java.lang.Error:未解決的編譯問題: (CaesarCipher.java:5) – yulana