Thursday, October 23, 2014

Help calling a string to another method.


Well I am back. I need to get the string encodedString from the method encode able to be used in the decode method.



Java Code:



public String encode(String plainText)
{
int prepareString;
int shiftChar;
String preparedString2 = prepareString(plainText);

String encodedString = "";
for(int c = 0 ; c < preparedString2.length();c++)
if(Character.isAlphabetic(preparedString2.charAt(c)))
{
encodedString = encodedString+shiftChar(preparedString2.charAt(c),shift);
}
return encodedString;
}
public String decode(String cipherText)
{

String cipherText = "";
for(int z = 0 ; z < encodedString.length();z++)
if(Character.isAlphabetic(encodedString.charAt(z)))
{
cipherText = cipherText+shiftChar(encodedString.charAt(z),-shift);
}
return cipherText;
}
}


No comments:

Post a Comment