Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Sep 24th, 2004, 10:17 AM   #1
chris-guyatt
Newbie
 
Join Date: Sep 2004
Posts: 3
Rep Power: 0 chris-guyatt is on a distinguished road
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
chris-guyatt is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC