diff --git a/librerie/exercise2/main b/librerie/exercise2/main new file mode 100755 index 0000000..972f20b Binary files /dev/null and b/librerie/exercise2/main differ diff --git a/librerie/exercise2/zmytest/test.cpp b/librerie/exercise2/zmytest/test.cpp index c84cace..dbe4cd7 100755 --- a/librerie/exercise2/zmytest/test.cpp +++ b/librerie/exercise2/zmytest/test.cpp @@ -85,6 +85,7 @@ void UseChosenType(DataStructure chosenDataStructure, DataType chosenDataType, I if(chosenDataType == DataType::integer){ StackVec stckvec; stckvec = generateRandomStackVecInt(); + StackIntFunctions(stckvec); } else if(chosenDataType == DataType::ffloat){ StackVec stckvec; @@ -142,6 +143,93 @@ void UseChosenType(DataStructure chosenDataStructure, DataType chosenDataType, I } } +template +void StackIntFunctions(T& stk){ + unsigned short int choice; + do{ + std::cout<>std::ws; + std::cin>>choice; + std::cout< +void PushInt(T& stk){ + int element; + std::cout<<"Element to push: "; + std::cin>>std::ws; + std::cin>>element; + stk.Push(element); +} + +template +void Pop(T& stk){ + stk.Pop(); +} + +template +void TopNPop(T& stk){ + std::cout<<"Element top & popped is: "< +void Top(T& stk){ + std::cout<<"Element on top is: "< +void Empty(T& stk){ + std::cout<<"Stack is "; + stk.Empty()? std::cout<<"" : std::cout<<"not "; + std::cout<<"empty"; +} + +template +void Size(T& stk){ + std::cout<<"Size is "< +void Clear(T& stk){ + stk.Clear(); + std::cout<<"Stack has been cleared."; +} + + lasd::QueueLst generateRandomQueueListInt(){ ulong dim = getDimension(); int tmp; @@ -154,7 +242,6 @@ lasd::QueueLst generateRandomQueueListInt(){ myqueue.Enqueue(tmp); std::cout< generateRandomQueueListFloat(){ @@ -169,7 +256,6 @@ lasd::QueueLst generateRandomQueueListFloat(){ myqueue.Enqueue(tmp); std::cout< generateRandomQueueListString(){ @@ -184,7 +270,6 @@ lasd::QueueLst generateRandomQueueListString(){ myqueue.Enqueue(tmp); std::cout< generateRandomQueueVecInt(){ myqueue.Enqueue(tmp); std::cout< generateRandomQueueVecFloat(){ @@ -215,7 +299,6 @@ lasd::QueueVec generateRandomQueueVecFloat(){ myqueue.Enqueue(tmp); std::cout< generateRandomQueueVecString(){ @@ -230,7 +313,6 @@ lasd::QueueVec generateRandomQueueVecString(){ myqueue.Enqueue(tmp); std::cout< generateRandomStackLstInt(){ myvec.Push(dist(gen)); std::cout< generateRandomStackLstFloat(){ @@ -257,7 +338,6 @@ lasd::StackLst generateRandomStackLstFloat(){ myvec.Push( float((round(distr(gen)*10000))/100) ); std::cout< generateRandomStackLstString(){ @@ -270,7 +350,6 @@ lasd::StackLst generateRandomStackLstString(){ myvec.Push( generateRandomString(dist(gen)) ); std::cout< generateRandomStackVecInt(){ myvec.Push(dist(gen)); std::cout< generateRandomStackVecFloat(){ @@ -298,8 +376,7 @@ lasd::StackVec generateRandomStackVecFloat(){ myvec.Push( (round(distr(gen)*10000))/100 ); std::cout< generateRandomStackVecString(){ ulong dim = getDimension(); @@ -311,7 +388,6 @@ lasd::StackVec generateRandomStackVecString(){ myvec.Push(generateRandomString(dist(gen))); std::cout< generateRandomStackVecInt(); lasd::StackVec generateRandomStackVecFloat(); lasd::StackVec generateRandomStackVecString(); +template +void StackIntFunctions(T&); + +template +void PushInt(T&); +template +void Pop(T&); +template +void TopNPop(T&); +template +void Top(T&); +template +void Empty(T&); +template +void Size(T&); +template +void Clear(T&); std::string generateRandomString(ulong); ulong getDimension();