Updated test coverage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Beaufort.java
|
||||
//Mattrixwv
|
||||
// Created: 02-23-22
|
||||
//Modified: 07-09-22
|
||||
//Modified: 04-16-23
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Beaufort{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Beaufort.class);
|
||||
protected static Logger logger = LoggerFactory.getLogger(Beaufort.class);
|
||||
|
||||
//Fields
|
||||
private String inputString; //This is the string that needs encoded/decoded
|
||||
private String outputString; //This is the string that is output after encoding/decoding
|
||||
private String keyword; //This is the keyword that is responsible for determining the offsets that you change each character by
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
protected String inputString; //This is the string that needs encoded/decoded
|
||||
protected String outputString; //This is the string that is output after encoding/decoding
|
||||
protected String keyword; //This is the keyword that is responsible for determining the offsets that you change each character by
|
||||
protected boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
protected boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
protected boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
//Internal ciphers
|
||||
private Atbash atbash; //The first step in encoding/decoding the cipher
|
||||
private Caesar caesar; //The second step in encoding/decoding the cipher
|
||||
private Vigenere vigenere; //The third step in encoding/decoding the cipher
|
||||
protected Atbash atbash; //The first step in encoding/decoding the cipher
|
||||
protected Caesar caesar; //The second step in encoding/decoding the cipher
|
||||
protected Vigenere vigenere; //The third step in encoding/decoding the cipher
|
||||
|
||||
//Ensures inputString constraints
|
||||
public void setInputString(String inputString) throws InvalidInputException{
|
||||
@@ -88,9 +88,20 @@ public class Beaufort{
|
||||
}
|
||||
}
|
||||
//Encodes the inputString and stores the result in outputString
|
||||
public void encode() throws InvalidKeywordException, InvalidInputException{
|
||||
protected void encode() throws InvalidKeywordException, InvalidInputException{
|
||||
logger.debug("Encoding");
|
||||
|
||||
code();
|
||||
}
|
||||
//Decodes the inputString and stores the result in outputString
|
||||
protected void decode() throws InvalidKeywordException, InvalidInputException{
|
||||
logger.debug("Decoding");
|
||||
|
||||
//Decoding is just encoding again
|
||||
code();
|
||||
}
|
||||
//Codes input and saves to output
|
||||
protected void code(){
|
||||
//Reverse the string
|
||||
logger.debug("Encoding with Atbash");
|
||||
String atbashString = atbash.encode(inputString);
|
||||
@@ -106,13 +117,6 @@ public class Beaufort{
|
||||
logger.debug("Saving output string '{}'", vigenereString);
|
||||
this.outputString = vigenereString;
|
||||
}
|
||||
//Decodes the inputString and stores the result in outputString
|
||||
public void decode() throws InvalidKeywordException, InvalidInputException{
|
||||
logger.debug("Decoding");
|
||||
|
||||
//Decoding is just encoding again
|
||||
encode();
|
||||
}
|
||||
|
||||
|
||||
//Constructor
|
||||
|
||||
Reference in New Issue
Block a user