Fixed bug where multiple operations before reset called threw error

This commit is contained in:
2019-03-07 12:48:24 -05:00
parent 6a74a06430
commit b9e3b5c2f5

View File

@@ -100,10 +100,10 @@ void Playfair::createGrid(){
//Put a check here that row == 5. If it doesn't then there is a problem
//TODO: Make this a propper exception throw rather than this
if(row < 5){
throw invalidGrid("smaller", row);
throw invalidGrid("small", row);
}
else if(row > 5){
throw invalidGrid("larger", row);
throw invalidGrid("large", row);
}
}
@@ -252,6 +252,8 @@ std::string Playfair::encode(){
* @return The encoded message
*/
std::string Playfair::encode(std::string keyword, std::string input){
//Reset the variables every time, just in case
reset();
try{
setKeyword(keyword);
}
@@ -346,6 +348,8 @@ std::string Playfair::decode(){
* @return The decoded message
*/
std::string Playfair::decode(std::string keyword, std::string input){
//Reset the variables every time, just in case
reset();
try{
setKeyword(keyword);
}