Im writing an encription program and it keeps saying their are 2 missing return statements :cry: , any ideas?
public class EncryptedMessage
{
public static final int NO_OF_LETTERS = 26; //a-z incl
public static final int NO_OF_NUMBERS = 10; //0-9 incl
public static final int NO_OF_CHARACTERS = NO_OF_LETTERS + NO_OF_NUMBERS;
private String message;
public static final char[][] cipherArray =
{{'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','0','1','2','3','4','5','6','7','8','9'},
{'!','"','£','$','%','^','&','*','(',')','_','#','@',':',';','{','}','','=','?','<','>','~','+','|','B','P','S','E','C','U','R', 'I','T','Y'}};
public EncryptedMessage()
{ message = ("");
}
public EncryptedMessage(Object o)
{ message = (String)o;
}
public EncryptedMessage(String s)
{ message = s;
}
public EncryptedMessage(int i)
{ message = Integer.toString(i);
}
public String encryptText()
{
//convert message to character array
char[] mess = message.toCharArray();
int len = mess.length;
//create a second array to store the encrypted text
char[] encrypted = new char[len];
//Get each cipher letter for each character and store in the character array
//outputText.
for(int i =0; i<=mess.length; i++)
{
encrypted=crypt(mess);
}
StringBuffer enText = new StringBuffer("");
//append character array to StringBuffer, convert to a String and trim off control characters
return ((enText.append(encrypted)).toString().trim());
}
public String decryptText()
{
//convert string to character array
char[] returnMess = message.toCharArray();
int messLen = returnMess.length;
//create a second array to store the encrypted text
char[] encrypted2 = new char[messLen];
//Get each cipher letter for each character and store in the character array
for(int i =0; i<=messLen; i++)
{
encrypted2=decrypt(returnMess);
}
StringBuffer enText = new StringBuffer("");
//append outputText to StringBuffer, convert to a String and trim off control characters
return ((enText.append(encrypted2)).toString().trim());
}
// All characters outside of the character subset should be left unencrypted.
public static char crypt(char c)
{
//look for the character in the top row of the cipher array
for(int i=0; i<=NO_OF_CHARACTERS;i++)
{
if(cipherArray[0]==c)
{
return cipherArray[0];
}
else
{
return c;
}
}
}
public static char decrypt(char c)
{
//look for the character in the bottom row of the cipher array
for(int i =0; i <=NO_OF_CHARACTERS;i++)
{
if(cipherArray[0]==c)
{
//return relevant encryted character or original character if not in character set
return cipherArray[0];
}
else
{
return c;
}
}
}
}
Thanx :lol: