1

プロジェクトを終了していますが、このエラーが引き続き発生します。PermutationData は static String[][] ROTOR_SPECS (配列) を持つ別のクラスであり、要素 x[0] が PermutationData 内にあるかどうかを確認しているため、取得できませんが、コンパイラは PermutationData を aa 変数として認識し続けます。クラス....私は今、ロータークラスの中にいます。

Rotor.java:90: エラー: シンボルが見つかりません

for (String[] x : PermutationData.ROTOR_SPECS) {
                  ^
symbol: variable PermutationData
location: class Rotor
        if (type() == x[0]) {
            Index1 = toIndex(x[1].charAt(p));

これは私の PermutationData.java クラスです。

class PermutationData {

/** The names and definitions of the rotors and reflectors in M4.  The
 *  first string in each entry is the name of a rotor or reflector.  The
 *  second is a 26-character string whose first character is the mapping
 *  (when the rotor is at the 'A' setting), of 'A' in the right-to-left
 *  direction, whose second is that of 'B', etc.
 *
 *  The third entry, if present, is the inverse of the
 *  second---the left-to-right permutation of the rotor.  It is
 *  not present for reflectors.
 *
 *  The fourth entry, if present, gives the positions of the
 *  notches. These are the settings of the rotors just before the
 *  wheels advanced (wheels advance before a character is
 *  translated).  Other written accounts of the Enigma generally
 *  show instead the character settings just after a character is
 *  coded (e.g., 'R', rather than 'Q', or 'A' rather than 'Z').
 *  The entry is absent in rotors that do not advance. */

static final String[][] ROTOR_SPECS = {
    { "I", "EKMFLGDQVZNTOWYHXUSPAIBRCJ", "UWYGADFPVZBECKMTHXSLRINQOJ",
      "Q" },
    { "II", "AJDKSIRUXBLHWTMCQGZNPYFVOE", "AJPCZWRLFBDKOTYUQGENHXMIVS",
      "E" },
    { "III", "BDFHJLCPRTXVZNYEIWGAKMUSQO", "TAGBPCSDQEUFVNZHYIXJWLRKOM",
      "V" },
    { "IV", "ESOVPZJAYQUIRHXLNFTGKDCMWB", "HZWVARTNLGUPXQCEJMBSKDYOIF",
      "J" },
    { "V", "VZBRGITYUPSDNHLXAWMJQOFECK", "QCYLXWENFTZOSMVJUDKGIARPHB",
      "Z" },
    { "VI", "JPGVOUMFYQBENHZRDKASXLICTW", "SKXQLHCNWARVGMEBJPTYFDZUIO",
      "ZM" },
    { "VII", "NZJHGRCXMYSWBOUFAIVLPEKQDT", "QMGYVPEDRCWTIANUXFKZOSLHJB",
      "ZM" },
    { "VIII", "FKQHTLXOCBJSPDZRAMEWNIUYGV", "QJINSAYDVKBFRUHMCPLEWZTGXO",
      "ZM" },
    { "BETA", "LEYJVCNIXWPBQMDRTAKZGFUHOS", "RLFOBVUXHDSANGYKMPZQWEJICT" },
    { "GAMMA", "FSOKANUERHMBTIYCWLQPZXVGJD", "ELPZHAXJNYDRKFCTSIBMGWQVOU" },
    { "B", "ENKQAUYWJICOPBLMDXZVFTHRGS" },
    { "C", "RDOBJNTKVEHMLFCWZAXGYIPSUQ" }
};

}

4

3 に答える 3

0

@alfasinの回答とともに、PermutationDataをインポートしたことを確認してください

于 2013-09-28T03:36:18.433 に答える
0

PermutationData.java クラスにはデフォルト レベルのパッケージ アクセスがあり、他のパッケージから呼び出していると思います。このため、PermutationData.java クラスにアクセスできません。

問題を解決できる PermutationData.java を公開してください。

ROTOR_SPECS は String[][] 型の変数です。そのため、最初にプログラムのどこかに保存し、他の変数に割り当ててから、その存在を確認できます。

これを実行してみてください。動作しています。

for (String[] x : PermutationData.ROTOR_SPECS) {  
             System.out.println(x[0]);
}
于 2013-09-28T04:41:28.517 に答える