[Solved] SOLVED:Laboratory Exercise Week 12 solution

30 $

File Name: SOLVED:Laboratory_Exercise_Week_12_solution.zip
File Size: 405.06 KB

SKU: [Solved] SOLVED:Laboratory Exercise Week 12 solution Category: Tag:

Or Upload Your Assignment Here:


Task One: String splitIn this task, you will define a class that stores a string and can split the string object into tokens according to the delimiters that given.Define a class stringSplit in a namespace MyLib in a file stringSplit.h. The class contains following data members: a string object; a delimiter object; a suitable (STL) container (such as vector, deque, list) object for tokens; an iterator object for the container which points the current token.Define proper constructor(s), set functions to set string and delimiters for the classstringSplit. Define the following member functions in the class stringSplit: Constructor(s). setString(const std::string &): The function set string for the class. setDelimiters(const std::string &): The function set delimiters for the class. void split(bool): The function can split the string into tokens according to thedelimiters. When the bool value is true, the tokens contain delimiters; when it is false, the tokens only contain non delimiter tokens. The iterator object initially points to the first token. bool hasMore(): The function will return true if more tokens left; return false when there is no more token. std::string next(): The function will return the token that the iterator points to, and the iterator points to the next token.Implement the member functions in a file stringSplit.cpp. You can download the file task1Main.cpp to test the member functions above in the class stringSplit.Testing:You can compile your programCC –o task1 task1Main.cpp stringSplit.cppThen run the program./task1The output data can be found in a text file task1.txt.Task Two:The program vectorProc.cpp intends to implement and test a template function:template bool same_elements(const vector that checks whether two vector containers have the same elements with the samemultiplicities. For example,“1 4 9 16 9 7 4 9 11” and “11 1 4 9 16 9 7 4 9” would be considered identical, but “1 4 9 16 97 4 9 11” and “11 11 7 9 16 4 1” would not.And a template function that removes duplicates from a vector container:template void remove_duplicates(vector Complete the implementation of these two functions. You will probably need one or more helper (template) functions for the implementation. Place the helper functions in the file vectorProc.cpp. Complete the main() function and test your implementation.You can download test files input1.txt, input2.txt and input3.txt from the web site to test your program.Testing:You can compile your programCC –o task2 vectorProc.cppThen run the program./task2 < input1.txtInput number of elements for integer v1: 9Input data: 1Input data: 4Input data: 9Input data: 16Input data: 9Input data: 7Input data: 4Input data: 9Input data: 11Input number of elements for integer v2: 9Input data: 11Input data: 1Input data: 4Input data: 9Input data: 16Input data: 9Input data: 7Input data: 4Input data: 9v1 and v2 contain same elements.After remove duplicates from v1, now it contains:1 4 9 16 7 11After remove duplicates from v2, now it contains:11 1 4 9 16 7Input number of elements for double v1: 5Input data: 1.5Input data: 4.3Input data: 9.6Input data: 16.2Input data: 9.6Input number of elements for double v2: 5Input data: 9.6Input data: 16.2Input data: 1.5Input data: 9.6Input data: 4.3v1 and v2 contain same elements.After remove duplicates from v1, now it contains:1.5 4.3 9.6 16.2After remove duplicates from v2, now it contains:9.6 16.2 1.5 4.3

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED:Laboratory Exercise Week 12 solution
30 $