Updating tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/Baconian.java
|
||||
//Mattrixwv
|
||||
// Created: 01-12-22
|
||||
//Modified: 04-15-23
|
||||
//Modified: 05-04-23
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class Baconian{
|
||||
protected static Logger logger = LoggerFactory.getLogger(Baconian.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(Baconian.class);
|
||||
|
||||
//Conversions
|
||||
protected static final ArrayList<String> code = new ArrayList<>(Arrays.asList(
|
||||
@@ -25,8 +25,9 @@ public class Baconian{
|
||||
"abbaa", "abbab", "abbba", "abbbb", "baaaa", "baaab", "baaba", "baabb", "baabb", "babaa", "babab", "babba", "babbb" //N-Z
|
||||
));
|
||||
protected String inputString; //The string that needs encoded/decoded
|
||||
protected String outputString; //The encoded/decoded string
|
||||
protected boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
protected String outputString; //The encoded/decoded string
|
||||
protected boolean preserveCapitals; //Persist capitals in the output string
|
||||
|
||||
|
||||
//Sets the input string
|
||||
protected void setInputStringEncode(String inputString) throws InvalidInputException{
|
||||
@@ -121,7 +122,7 @@ public class Baconian{
|
||||
logger.debug("Saving output string '{}'", outputString);
|
||||
}
|
||||
//Decodes the inputString and stores the result in outputString
|
||||
protected String decode(){
|
||||
protected void decode(){
|
||||
logger.debug("Decoding");
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
@@ -154,7 +155,6 @@ public class Baconian{
|
||||
//Save and return the output
|
||||
outputString = output.toString();
|
||||
logger.debug("Saving output string '{}'", outputString);
|
||||
return outputString;
|
||||
}
|
||||
|
||||
//Constructor
|
||||
@@ -166,14 +166,7 @@ public class Baconian{
|
||||
reset();
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
}
|
||||
//Returns the outputString
|
||||
public String getOutputString(){
|
||||
return outputString;
|
||||
}
|
||||
//Returns the inputString
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
}
|
||||
|
||||
//Sets the inputString and encodes the message
|
||||
public String encode(String inputString) throws InvalidInputException{
|
||||
reset();
|
||||
@@ -185,9 +178,18 @@ public class Baconian{
|
||||
public String decode(String inputString) throws InvalidCharacterException, InvalidInputException{
|
||||
reset();
|
||||
setInputStringDecode(inputString);
|
||||
return decode();
|
||||
decode();
|
||||
return outputString;
|
||||
}
|
||||
//Makes sure all of the variables are empty
|
||||
|
||||
//Getters
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
}
|
||||
public String getOutputString(){
|
||||
return outputString;
|
||||
}
|
||||
//Makes sure all variables are empty
|
||||
public void reset(){
|
||||
logger.debug("Resetting fields");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user