diff --git a/include/playunfair.h b/include/playunfair.h index af0ea67d187e6f02f2f5b839b6d9429fdc77ad48..80946733a52946cc1fd9d7d358a069562bacd995 100644 --- a/include/playunfair.h +++ b/include/playunfair.h @@ -11,5 +11,6 @@ int filter2(std::string text); int filter3(std::string text); int filter4(std::string text); int filter5(std::string text); +int filter6(std::string text); int filter7(std::string text); int filter8(std::string text); diff --git a/playunfair.cpp b/playunfair.cpp index 08311ae49056452cef08c64699b2a1395e83ade0..2f15c857fadc40ef78c3acfc38ee2f97782e09c7 100644 --- a/playunfair.cpp +++ b/playunfair.cpp @@ -26,7 +26,7 @@ int main(int argc, char *argv[]){ crip = text.str(); parser(crip); - std::cout << crip << std::endl; + //std::cout << crip << std::endl; dict.open(dictName, std::ifstream::in); if(!dict.good()){ @@ -75,6 +75,8 @@ int filter(std::string text){ return REJECTED; else if (filter5(text) == REJECTED) return REJECTED; + else if (filter6(text) == REJECTED) + return REJECTED; else if (filter7(text) == REJECTED) return REJECTED; else @@ -194,6 +196,23 @@ int filter5(std::string text){ return rej; } +int filter6(std::string text){ + // ('b'|'c'|'d'|'f'|'h'|'k'|'p'|'q'|'t'|'w'|'y') + !(vogal|'r'|'h'|'l') || + size_t i; + int rej = ACCEPTED; + for (i=0; i<text.size()-1; ++i){ + if(text[i]=='b' || text[i]=='c' || text[i]=='d' || text[i]=='f' || + text[i]=='h' || text[i]=='k' || text[i]=='p' || text[i]=='q' || + text[i]=='t' || text[i]=='w' || text[i]=='y'){ + if(!isVowel(text[i+1]) && text[i+1]!='r' && text[i+1]!='h' && text[i+1]!='l'){ + rej = REJECTED; + break; + } + } + } + return rej; +} + int filter7(std::string text){ size_t i; int rej = ACCEPTED;