Could someone help me please
I am doing a piece of code in RMI here is what i have come up with up to now:
publicclass cipherimpl
extends java.rmi.server.UnicastRemoteObject
implements cipher{
public cipherimpl()
throws java.rmi.RemoteException{
super();
}
char[] tempArray;
int b = 3;
public String encrypt(String nameofString,int b)
throws java.rmi.RemoteException{
tempArray = nameofString.toCharArray();
char c =char[0];
int c1 = (int) c;
c2 = c1+b;
return nameofString;
}
public String decrypt(String nameofString,int b)
throws java.rmi.RemoteException{
tempArray = nameofString.toCharArray();
char d =char[0];
int d1 = (int) d;
d2 = d2-b;
return nameofString;
}
}
I also have a code called chiper.java which defines the two methods encrypt and decrypt.
For the impl file i need to make it use the Caesar Cipher method where there is an integer and this integer is used to encrytp a word so if the integer is equal to 1 each of the letters in the word are incremented by 1 so if the word "HELLO" was inputted the output would be "IFMMP" if u get what i mean but i am finding it difficult to put into code.
Could someone give me a few clues please.
Thanx
MARK
[2369 byte] By [
Liver_Lad] at [2007-9-30 23:27:47]

It is a task i have been given to do.
I have studied Java but still don't get the grasp of it
the main help i need with this piece of code is how to tell the program to increment a word by 1 when encrypt method is called
And to decrement the word by 1 when the decrypt method is called.
I would be honoured if you could help me
mate, i wasn't saying why are you messing with RMI, what I mean was why are you trying to do it all at once. Try to break down the problem. If all you want to do is to increment the character by one then the simplest way to do it is to set up an array of all the letters of the alphabet. Iterate over the string getting each character. Look it up in the array, and then get the next one, and add that to an output StringBuffer. When you have reached the end of the input string, toString() the StringBuffer, and you are done.
Fundamentally, programming is all about breaking problems up. If you try and look at everything at once you will either go mad, or not be able to cope.
HTH
Oh and for decrypt, just get the previous one!
Encryption and Decryption share some behaviour e.g. the iterating over the string, the StringBuffer, the array lookup etc. You can farm this out into one single method, and then only the direction in which you look for the next character will be different in the encrypt and decrypt methods.
Right. Get the CipherBean working without RMI. Once you have that working, just wrap it in RMI or, better yet, let your RMI server instantiate your CipherBean and just use it to accomplish the task.
It's called "decomposition" or "divide and conquer". Solve big problems by dividing them up into smaller, more manageable pieces.
%