1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: #include "ArrayList.h" 5: #include <iostream> 6: #include <string> 8: int main() 9: { 10: ListInterface<std::string>* listPtr = new ArrayList<std::string>(); 11: std::string data[] = {"one", "two", "three", "four", "five", "six"}; 12: std::cout << "isEmpty: returns " << listPtr –>isEmpty() 13: << "; should be 1 (true)" << std::endl; 14: for (int i = 0; i < ITEM_COUNT; i++) 15: { 16: if (listPtr –>insert(i + 1, data[i])) 17: { 18: try 19: { 20: std::cout << "Inserted " << listPtr –>getEntry(i + 1) 21: << " at position " << (i + 1) << std::endl; 22: } 23: catch (std::logic_error except) 24: { 25: std::cout << "Failed to get entry at position " 26: << (i + 1) << std::endl; 27: } 28: } 29: else 30: std::cout << "Cannot insert " << data[i] << " at position " << (i + 1) 31: << std::endl; 32: } // end for 33: return 0; 34: } // end main