Updating tests

This commit is contained in:
2023-05-05 20:19:27 -04:00
parent b3ca4754ea
commit 9c41f10576
45 changed files with 2729 additions and 2239 deletions

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Caesar.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 04-16-23
//Modified: 05-04-23
package com.mattrixwv.cipherstream.monosubstitution;
@@ -12,15 +12,16 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
public class Caesar{
protected static Logger logger = LoggerFactory.getLogger(Caesar.class);
private static final Logger logger = LoggerFactory.getLogger(Caesar.class);
//Fields
protected String inputString; //The string that needs encoded/decoded
protected String outputString; //The encoded/decoded string
protected int shift; //The amount that you need to shift each letter
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
//Settings
protected boolean preserveCapitals; //Persist capitals in the output string
protected boolean preserveWhitespace; //Persist whitespace in the output string
protected boolean preserveSymbols; //Persist symbols in the output string
//Sets shift and makes sure it is within the propper bounds
protected void setShift(int shiftAmount){
@@ -63,7 +64,7 @@ public class Caesar{
}
}
//Encodes the inputString and stores the result in outputString
protected String encode(){
protected void encode(){
logger.debug("Encoding");
StringBuilder output = new StringBuilder();
@@ -109,10 +110,9 @@ public class Caesar{
outputString = output.toString();
logger.debug("Saving encoded string '{}'", outputString);
return outputString;
}
//Decodes the inputString and stores the result in outputString
protected String decode(){
protected void decode(){
logger.debug("Decoding");
StringBuilder output = new StringBuilder();
@@ -162,7 +162,6 @@ public class Caesar{
outputString = output.toString();
logger.debug("Saving decoded string '{}'", outputString);
return outputString;
}
//Constructor
@@ -184,29 +183,29 @@ public class Caesar{
reset();
setShift(shiftAmount);
setInputString(inputString);
return encode();
encode();
return outputString;
}
//Sets the shift and inputString and decodes the message
public String decode(int shiftAmount, String inputString) throws InvalidInputException{
reset();
setShift(shiftAmount);
setInputString(inputString);
return decode();
decode();
return outputString;
}
//Returns the inputString
//Getters
public String getInputString(){
return inputString;
}
//Returns shift
public int getShift(){
return shift;
}
//Returns the outputString
public String getOutputString(){
return outputString;
}
//Makes sure all of the variables are empty
//Makes sure all variables are empty
public void reset(){
logger.debug("Resetting fields");