diff --git a/librerie/exercise2/main b/librerie/exercise2/main deleted file mode 100755 index 6fe20f5..0000000 Binary files a/librerie/exercise2/main and /dev/null differ diff --git a/librerie/exercise2/main.cpp b/librerie/exercise2/main.cpp index a25e136..7372d48 100755 --- a/librerie/exercise2/main.cpp +++ b/librerie/exercise2/main.cpp @@ -19,7 +19,6 @@ int main() { std::cout << "Lasd Libraries 2020" << std::endl; - lasdtest(); menu(); return 0; } diff --git a/librerie/exercise2/zmytest/test.cpp b/librerie/exercise2/zmytest/test.cpp index 82a94e4..c84cace 100755 --- a/librerie/exercise2/zmytest/test.cpp +++ b/librerie/exercise2/zmytest/test.cpp @@ -5,17 +5,13 @@ using namespace lasd; + void menu(){ -} - -/* -void menu(){ - - unsigned short int choice; DataStructure chosenDataStructure; DataType chosenDataType; Implementation chosenImplementation; + do{ std::cout<<"1. Use your tests (to be used by the professor)"<>std::ws; std::cin>>choice; - }while(!(choice>0 && choice<4)); + }while(!(choice>0 && choice<3)); if(choice==1) return Implementation::vector; else if(choice==2) @@ -87,20 +83,252 @@ void UseChosenType(DataStructure chosenDataStructure, DataType chosenDataType, I if(chosenDataStructure == DataStructure::stack){ if(chosenImplementation == Implementation::vector){ if(chosenDataType == DataType::integer){ - lasd::StackVec myvec; - myvec = generateVectorOfIntegers(); - VectorIntegerFunctions(myvec); - }else if(chosenDataType == DataType::ffloat){ - lasd::StackVec myvec; - myvec = generateVectorOfFloat(); - VectorFloatFunctions(myvec); - }else if(chosenDataType == DataType::sstring){ - lasd::StackVec myvec; - myvec = generateVectorOfStrings(); - VectorStringFunctions(myvec); + StackVec stckvec; + stckvec = generateRandomStackVecInt(); + } + else if(chosenDataType == DataType::ffloat){ + StackVec stckvec; + stckvec = generateRandomStackVecFloat(); + } + else if(chosenDataType == DataType::sstring){ + StackVec stckvec; + stckvec = generateRandomStackVecString(); + } + } + else if(chosenImplementation == Implementation::list){ + if(chosenDataType == DataType::integer){ + StackLst stcklst; + stcklst = generateRandomStackLstInt(); + } + else if(chosenDataType == DataType::ffloat){ + StackLst stcklst; + stcklst = generateRandomStackLstFloat(); + } + else if(chosenDataType == DataType::sstring){ + StackLst stcklst; + stcklst = generateRandomStackLstString(); + } + } + } + else if(chosenDataStructure == DataStructure::queue){ + if(chosenImplementation == Implementation::vector){ + if(chosenDataType == DataType::integer){ + QueueVec queuevec; + queuevec = generateRandomQueueVecInt(); + } + else if(chosenDataType == DataType::ffloat){ + QueueVec queuevec; + queuevec = generateRandomQueueVecFloat(); + } + else if(chosenDataType == DataType::sstring){ + QueueVec queuevec; + queuevec = generateRandomQueueVecString(); + } + } + else if(chosenImplementation == Implementation::list){ + if(chosenDataType == DataType::integer){ + QueueLst queuelist; + queuelist = generateRandomQueueListInt(); + } + else if(chosenDataType == DataType::ffloat){ + QueueLst queuelist; + queuelist = generateRandomQueueListFloat(); + } + else if(chosenDataType == DataType::sstring){ + QueueLst queuelist; + queuelist = generateRandomQueueListString(); } } } - } -*/ + +lasd::QueueLst generateRandomQueueListInt(){ + ulong dim = getDimension(); + int tmp; + QueueLst myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(0,1000); + std::cout< generateRandomQueueListFloat(){ + ulong dim = getDimension(); + float tmp; + QueueLst myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_real_distribution distr(0,5); + std::cout< generateRandomQueueListString(){ + ulong dim = getDimension(); + std::string tmp; + QueueLst myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(1,5); + std::cout< generateRandomQueueVecInt(){ + ulong dim = getDimension(); + int tmp; + QueueVec myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(0,1000); + std::cout< generateRandomQueueVecFloat(){ + ulong dim = getDimension(); + float tmp; + QueueVec myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_real_distribution distr(0,5); + std::cout< generateRandomQueueVecString(){ + ulong dim = getDimension(); + std::string tmp; + QueueVec myqueue; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(1,5); + std::cout< generateRandomStackLstInt(){ + ulong dim = getDimension(); + StackLst myvec; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(0,1000); + std::cout< generateRandomStackLstFloat(){ + ulong dim = getDimension(); + StackLst myvec; + std::default_random_engine gen(std::random_device{}()); + std::uniform_real_distribution distr(0,5); + std::cout< generateRandomStackLstString(){ + ulong dim = getDimension(); + StackLst myvec; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(1,5); + std::cout< generateRandomStackVecInt(){ + ulong dim = getDimension(); + StackVec myvec; + + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(0,1000); + std::cout< generateRandomStackVecFloat(){ + ulong dim = getDimension(); + StackVec myvec; + std::default_random_engine gen(std::random_device{}()); + std::uniform_real_distribution distr(0,5); + std::cout< generateRandomStackVecString(){ + ulong dim = getDimension(); + StackVec myvec; + std::default_random_engine gen(std::random_device{}()); + std::uniform_int_distribution dist(1,5); + std::cout< character('a','z'); + char newString[dim+1]; + for(int i=0;i>dimension; + return dimension; +} diff --git a/librerie/exercise2/zmytest/test.hpp b/librerie/exercise2/zmytest/test.hpp index cd36c25..0d75187 100755 --- a/librerie/exercise2/zmytest/test.hpp +++ b/librerie/exercise2/zmytest/test.hpp @@ -14,10 +14,29 @@ enum class DataStructure{stack,queue}; enum class DataType{integer,ffloat,sstring}; enum class Implementation{vector,list}; + void menu(); + DataType ChooseDataType(); //choose data type DataStructure ChooseDataStructure(); -void UseChosenType(DataStructure, DataType); +Implementation ChooseImplementation(); +void UseChosenType(DataStructure, DataType, Implementation); + +lasd::QueueLst generateRandomQueueListInt(); +lasd::QueueLst generateRandomQueueListFloat(); +lasd::QueueLst generateRandomQueueListString(); +lasd::QueueVec generateRandomQueueVecInt(); +lasd::QueueVec generateRandomQueueVecFloat(); +lasd::QueueVec generateRandomQueueVecString(); +lasd::StackLst generateRandomStackLstInt(); +lasd::StackLst generateRandomStackLstFloat(); +lasd::StackLst generateRandomStackLstString(); +lasd::StackVec generateRandomStackVecInt(); +lasd::StackVec generateRandomStackVecFloat(); +lasd::StackVec generateRandomStackVecString(); + +std::string generateRandomString(ulong); +ulong getDimension(); /* ************************************************************************** */ #include"test.cpp"