Fixed typos

This commit is contained in:
2022-01-04 22:47:14 -05:00
parent f7d2f088de
commit cb7bf18836
2 changed files with 9 additions and 6 deletions

View File

@@ -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){

View File

@@ -51,7 +51,7 @@ public class TestPlayfair{
output = cipher.decode(keyword, inputString);
assertEquals("Playfair failed symbol decoding.", correctOutput, output);
//Test mixed case, whtiespace, symbol decoding
//Test mixed case, whitespace, symbol decoding
inputString = "Bmod zbx dnab ek - udm@uixmm+ouvif";
keyword = "Playfair Example";
correctOutput = "Hide the gold in - the@trexe+stump";