Question: Use C++ template mechanism and define a generic SortedList ADT. Implement the SortedList ADT using a dynamically allocated array. Use SortedList.cpp and SortedList.h to implement
Use C++ template mechanism and define a generic SortedList ADT. Implement the SortedList ADT using a dynamically allocated array. Use SortedList.cpp and SortedList.h to implement a simple student class and tester.cpp
Implement a simple Student class with two data members: StudentID (int) and Student name (String). Implement a constructor and setter functions for class Student. You must also overload operators ==, < and > for class Student in order to be able to compare objects. For example, the operator == should return true if compared student objects have the same StudentID and false otherwise.
Code your SortedList driver program:
Implement tester.cpp. This program should test the SortedList ADT. The program will continue reading commands and data from the input file inFile until the command Quit is read. Commands are: (isEmpty, isFull, makeEmpty, getLength, get, insertItem, deleteItem, merge and printList) The program should write output to an output file outFile.txt.
Your test driver should define these lists:
SortedList
SortedList
SortedList
Your test driver should read list data type from the use in order to be able to test your implementation for the three types: int, char and Student (see the code below). make sure you are using the same commands and be aware of case sensitivity e.g. isEmpty not IsEmpty which will cause your program to fail the test.
----------
SortedList.cpp
#include "SortedList.h" #include
template
template
template
template
template
while(location < length) { if(newItem
info[location] = newItem; length++; }
template length--; } template template template template SortedList.h #include template private: int length; int MAX_ITEMS; ItemType *info; int findIndex(ItemType item); }; tester.cpp #include Cout<< Enter Elements Type 1 for integer 2 for character 3 for Student ; cin>> datatype; switch (datatype) { case 1: testIntegersList(); break; } void testIntegersList() { ifstream inFile; ofstream outFile; inFile.open(intcommands.txt); outFile.open(outFile.txt); inFile>> command; // read commands from a text file SortedList { ifstream inFile; ofstream outFile; inFile.open(studcommands.txt); outFile.open(outFile.txt); inFile>> command; // read commands from a text file #include
using namespace std;
void testIntegersList(); void testCharactersList(); void testStudentsList(); int main()
{ int number; string command; int datatype;
// Prompt user to enter type of elements
break; case 2: testCharactersList();
break; case 3: testStudentsList();
if( list.isEmpty()) outFile << list is empty;
else outFile << list is not empty;
else if (command == inserItem) { inFile>> number;
list.inserItem(number); }
.......... inFile>> command;} // while } // testIntegersList
void testStudentsList()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
