Fixed typos
This commit is contained in:
@@ -45,7 +45,7 @@ public class Playfair{
|
||||
private String inputString; //The message that needs to be encoded/decoded
|
||||
private String outputString; //The encoded/decoded message
|
||||
private String keyword; //The keyword used to create the grid
|
||||
private char[][] grid; //The grid used to encoded/decode the message
|
||||
private char[][] grid; //The grid used to encode/decode the message
|
||||
//Create the grid from the keyword
|
||||
private void createGrid(){
|
||||
for(int row = 0;row < 5;++row){
|
||||
@@ -156,13 +156,13 @@ public class Playfair{
|
||||
this.inputString = inputString;
|
||||
}
|
||||
}
|
||||
//Returns the inputs string ready for encoding
|
||||
//Returns the input string ready for encoding
|
||||
private String getPreparedInputString(){
|
||||
String cleanString = inputString.toUpperCase();
|
||||
cleanString = cleanString.replaceAll("[^A-Z]", "");
|
||||
return cleanString;
|
||||
}
|
||||
//Strips invalid character from the keyword and creates the grid
|
||||
//Strips invalid characters from the keyword and creates the grid
|
||||
private void setKeyword(String key){
|
||||
//Change everything to uppercase
|
||||
key = key.toUpperCase();
|
||||
@@ -223,7 +223,7 @@ public class Playfair{
|
||||
}
|
||||
outputString = fullOutput.toString();
|
||||
}
|
||||
//Encoded inputString using the Playfair cipher and stores the result in outputString
|
||||
//Encodes inputString using the Playfair cipher and stores the result in outputString
|
||||
private String encode() throws Exception{
|
||||
StringBuilder output = new StringBuilder();
|
||||
int inputCnt = 0;
|
||||
@@ -347,6 +347,9 @@ public class Playfair{
|
||||
//Makes sure all variables are empty
|
||||
public void reset(){
|
||||
grid = new char[5][5];
|
||||
inputString = "";
|
||||
outputString = "";
|
||||
keyword = "";
|
||||
}
|
||||
//Gets
|
||||
public char getReplaced(){
|
||||
@@ -354,7 +357,7 @@ public class Playfair{
|
||||
}
|
||||
public void setReplaced(char replaced) throws InvalidCharacterException{
|
||||
if(!Character.isAlphabetic(replaced)){
|
||||
throw new InvalidCharacterException("The replaced characgter must be a letter");
|
||||
throw new InvalidCharacterException("The replaced character must be a letter");
|
||||
}
|
||||
|
||||
if(replaced == replacer){
|
||||
|
||||
Reference in New Issue
Block a user