no copying
you can download all the files and view the instruction in the link below, https://github.com/Seneca-244200/OOP-Workshops/tree/main/WS10 here the files need to completed Collection.h Car.h Car.cpp Employee.h Employee.cpp Student.h Student.cpp ReadWrite.h ReadWrite.cpp main.cpp serchNlist.h
here is the instruction if the link doesn't work for any reason
PART 1 (100%) Look at the code provided in the Collection template module, study it and understand it. The Collection class is a template that works like a dynamic array of objects and resizes itself as objects are added to it. The code snippet below demonstrates how Collection works: Collection Cdbl; Cdbl.add(1.23); Cdbl.add(2.34); Cdbl.add(3.45); cout << "There are " << Cdbl.size() << " items in the Collection!" << endl; for(int i=0; i< Cdbl.size();i++){ cout << Cdbl[i] << endl; } Output: There are 3 items in the Collection! 1.23 2.34 3.45 Supplied Modules: Collection ReadWrite Employee Student Car Do not modify these modules! Look at the code and make sure you understand them. Modules that you will modify (The searchNlist module and the main module)searchNlist module Implement this module in 'searchNlist.h' header file. "check": to check a value in a compound type array against a given key is a specific index "search": to search through a compound type array (using the check function before) and insert the matches found into a Collection of the same compound type. "listArrayElements": to list elements of an array with a title "sizeCheck": to compare the sizes of two collections of the same compound type. check function template Create a function template called check to check a value in a compound type array against a given key in a specific index An array of templated objects; the same type as the Collection type. (template type 1) An integer variable that represents the index to use in the comparison A key templated value to search for, in the array of objects. (template type 2) The check function is rather simple and will return true or false based on the following condition: if the element at index i of the array equals the key or not Use the "==" operator to check for a match between the objects and the key. This operator is overloaded in each testing class used. search function template Create a function template called search that accepts four arguments in any order you prefer: An array of templated objects; the same type as the Collection type. (template type 1) An integer represents the number of elements in the array of objects A key templated value to search for, in the array of objects. (template type 2) A reference to a Collection of templated objects (template type 1). The Collection is defined in Collection.h The search function template returns a bool that is true only if at least one match to the key is found in the array of objects and false otherwise. The search function goes through all the elements of the array of objects and adds all the matches found to the Collection. You are required to use the check function created above for a match between the object at a specific location and the key listArrayElements function template Lists all the elements of an array. Create a function template called search that accepts three arguments in any order you prefer: A const char* for a Title to be printed as the Title of the list. A constant array of templated objects (template type) The number of the elements of the array. This function first prints the Title and then goes to newline. Then it will print the row number and then insert each element of the array into cout with a newline attached. For example, if this function is called for the following array of integers. int a[]{10,20,30,40}; using the Title value of "INTEGERS" and the number of elements as 4, the output would be like the following. INTEGERS 1: 10 2: 20 3: 30 4: 40 sizeCheck function template Create a function template called sizeCheck that accepts two arguments in any order you prefer: A reference to a Collection of templated objects representing collection 1. The Collection is defined in Collection.h A reference to a Collection of templated objects representing collection 2. The Collection is defined in Collection.h This function simply compares the sizes of the two collections and return true if the size of the first collection is larger and false otherwise. Template type requirements Have a comment section for each function and explain what requirements each type of your templates must have to be able to work with your logic. Then also copy these comments to the part 2 reflection of the workshop. The main module In this workshop you are modifying the main module. Make sure to update the comments at the top to reflect your work on the module Modify the main module and call the search function at the condition of the five if statements in the source code. See the comments in main.cpp on where to use this function Modify the main module and call the sizeCheck function at the condition of the specified if statement in the source code. See the comments in main.cpp on where to use this function Also, call the listArrayElement function four times before the first three if statements and at the end of the main() function to list the elements of the integer array a. See the comments in main.cpp on where to use this function // Workshop 10: // Version: 2.0 // Date: 2021-11-18 // Author: Fardad Soleimanloo // // Description: // This file tests the lab section of your workshop // Modify the main function as stated in the workshop description ///////////////////////////////////////////// #include #include "Car.h" #include "Employee.h" #include "ReadWrite.h" #include "Student.h" #include "Collection.h" #include "searchNlist.h" using namespace std; using namespace sdds; int main() { Car C[7] = { Car("GVFGHI", "Tesla Model S"), Car("ABCDEF", "BMW 320"), Car("CDEFGH", "Ford Festiva"), Car("BCDEFG", "Ford Festiva"),Car("GVDGHI", "Tesla Model 3"), Car("EFGHIJ", "Nissan Maxima"), Car("GVDEFG", "Tesla Model X") }; Student S[6] = { Student(23456, "Lisa Simpson",4.0),Student(45678, "Ralph Wiggum",2.1), Student(56789, "Milhouse Van Houten",4.0), Student(67890, "Todd Flanders", 3.5), Student(34567, "Nelson Muntz",3.0),Student(12345, "Bart Simpson",1.5) }; Employee E[6] = { Employee(213456, "Carl Carlson", 62344.56,111), Employee(122345, "Mindy Simmons", 65432.44,222), Employee(435678, "Lenny Leonard", 43213.22,111), Employee(546789, "Waylon Smithers", 654321.55,333), Employee(657890, "Frank Grimes", 34567.88,333), Employee(364567, "Homer Simpson", 55432.11,111) }; //these collections will hold the results of the searches Collection Cres1; Collection Cres2; Collection Sres; CollectionEres; // Call the listArrayElements to list all cars in the array C, Title: "All the cars:", size is 7 listArrayElements(......................); cout << "Searching for Tesla cars: " << endl; // Call the search function to search the array C // and store the matches in Cres1 passing "a" as the key argument if (search(......................)) { cout << Cres1.size() << " match" << (Cres1.size() == 1 ? "" : "es") << " found:" << endl; for (int i = 0; i < Cres1.size(); i++) { cout << (i + 1) << ": " << Cres1[i] << endl; } } else { cout << "No matches found!" << endl; } cout << endl; // Call the search function to search the array C // and store the matches in Cres2 passing "b" as the key argument if (search(......................)) { cout << Cres2.size() << " match" << (Cres2.size() == 1 ? "" : "es") << " found:" << endl; for (int i = 0; i < Cres1.size(); i++) { cout << (i + 1) << ": " << Cres1[i] << endl; } } else { cout << "No matches found!" << endl; } cout << endl; //call the function sizeCheck and pass the resulted collections from the previous two searches // print "Collection 1 got more results!!", "Collection 2 got more results!!" or "equal results" if (sizeCheck(......................)) cout << "Collection 1 got more results!!" << endl; else cout << "Collection 1 got less than or equal collection 2 results!!" << endl; cout << endl; // Call the listArrayElements to list all the students, Title: "All students:" listArrayElements(......................); cout << "Searching for students with 4.0 Gpa:" << endl; // Call the search function to search the array S // and store the matches in Sres passing 4.0 as the key argument if (search(......................)) { cout << Sres.size() << " match" << (Sres.size() == 1 ? "" : "es") << " found:" << endl; for (int i = 0; i < Sres.size(); i++) { cout << (i + 1) << ": " << Sres[i] << endl; } } else { cout << "No matches found!" << endl; } cout << endl; // Call the listArrayElements to list all the employees, Title: "All employees:" listArrayElements(......................); cout << "Searching for employees who share office number 111:" << endl; // Call the search function to search the array E // and store the matches in Eres passing 111 as the key argument if (search(......................)) { cout << Eres.size() << " match" << (Eres.size() == 1 ? "" : "es") << " found:" << endl; for (int i = 0; i < Eres.size(); i++) { cout << (i + 1) << ": " << Eres[i] << endl; } } else { cout << "No matches found!" << endl; } cout << endl; cout << "Searching for employees who share office number 555:" << endl; // Call the search function to search the array E // and store the matches in Eres passing 555 as the key argument if (search(......................)) { cout << Eres.size() << " match" << (Eres.size() == 1 ? "" : "es") << " found:" << endl; for (int i = 0; i < Eres.size(); i++) { cout << (i + 1) << ": " << Eres[i] << endl; } } else { cout << "No matches found!" << endl; } cout << endl; int a[]{ 10,20,30,40,50,60 }; // Call the listArrayElements to list all the integers in the array a // Title: "INTEGERS" listArrayElements(......................); return 0; } output All the cars: 1: GVFGHI Tesla Model S 2: ABCDEF BMW 320 3: CDEFGH Ford Festiva 4: BCDEFG Ford Festiva 5: GVDGHI Tesla Model 3 6: EFGHIJ Nissan Maxima 7: GVDEFG Tesla Model X Searching for Tesla cars: 6 matches found: 1: GVFGHI Tesla Model S 2: CDEFGH Ford Festiva 3: BCDEFG Ford Festiva 4: GVDGHI Tesla Model 3 5: EFGHIJ Nissan Maxima 6: GVDEFG Tesla Model X
No matches found!
Collection 1 got more results!!
All students: 1: 23456 Lisa Simpson GPA: 4.0 2: 45678 Ralph Wiggum GPA: 2.1 3: 56789 Milhouse Van Houten GPA: 4.0 4: 67890 Todd Flanders GPA: 3.5 5: 34567 Nelson Muntz GPA: 3.0 6: 12345 Bart Simpson GPA: 1.5 Searching for students with 4.0 Gpa: 2 matches found: 1: 23456 Lisa Simpson GPA: 4.0 2: 56789 Milhouse Van Houten GPA: 4.0
All employees: 1: 213456 Carl Carlson (Office# 111) Salary: $62344.56 2: 122345 Mindy Simmons (Office# 222) Salary: $65432.44 3: 435678 Lenny Leonard (Office# 111) Salary: $43213.22 4: 546789 Waylon Smithers (Office# 333) Salary: $654321.55 5: 657890 Frank Grimes (Office# 333) Salary: $34567.88 6: 364567 Homer Simpson (Office# 111) Salary: $55432.11 Searching for employees who share office number 111: 3 matches found: 1: 213456 Carl Carlson (Office# 111) Salary: $62344.56 2: 435678 Lenny Leonard (Office# 111) Salary: $43213.22 3: 364567 Homer Simpson (Office# 111) Salary: $55432.11
Searching for employees who share office number 555: No matches found!
INTEGERS 1: 10 2: 20 3: 30 4: 40 5: 50 6: 60 Files to submit Collection.h Car.h Car.cpp Employee.h Employee.cpp Student.h Student.cpp ReadWrite.h ReadWrite.cpp main.cpp serchNlist.h