|
Newbie
Join Date: Sep 2004
Posts: 3
Rep Power: 0 
|
Hi,
As a part of a java refresher course at university, we are being asked to create a Caesar cipher program that manipulates strings. So far ive created to char[] one called 'translator' and the other is alphabet. in my CaesarMap constructor ive initialised translator to a new array of 26 (of course) but im not sure how i can 'add' to an array somehow. just basically, i need help. ive forgotten to mention how. we are given a key (from somewhere) and that key is added to the alphabet array to create the corresponding letter in the same position in the translator array. Ok, so now ure completely confused!? Good. Me too. hehe. heres some code (my cursors been blinking for ages now):
package cipher;
class CaesarMap
{
char[] translator;
char[] alphabet = new char['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'];
public CaesarMap(int key)
{
translator = new char[26]; /* our "enciphered" array of alphabet */
int modKey = key % 26; /* this makes sure endless loops are not made */
for(int i /* it is here that i am stuck and my cursor is blinking... */
}
private char translate(char c)
{
return c;
}
}
erm, firstly i dont even know what ive done in the constructor is "right". basically ... HELP PLZ! :s im already worried. ANY help appreciated GREATLY! hehe.
--Christopher Guyatt
|