Source of for_bagTester.cpp


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: // The following statements are from Section 3.2.6.
  5: // Add them to the function bagTester given in Listing 3-2.
  6: // (Note that the using statements that appear in Listing 3-2 make std::
  7: // unnecessary for cout and endl.)
  8:    cout << "contains(\"three\"): returns " << bag.contains("three")
  9:         << "; should be 1 (true)" << endl;
 10:    cout << "contains(\"ten\"): returns " << bag.contains("ten")
 11:         << "; should be 0 (false)" << endl;
 12:    cout << "getFrequencyOf(\"one\"): returns "
 13:         << bag.getFrequencyOf("one") << " should be 2" << endl;
 14:    cout << "remove(\"one\"): returns " << bag.remove("one")
 15:         << "; should be 1 (true)" << endl;
 16:    cout << "getFrequencyOf(\"one\"): returns "
 17:         << bag.getFrequencyOf("one") << " should be 1" << endl;
 18:    cout << "remove(\"one\"): returns " << bag.remove("one")
 19:         << "; should be 1 (true)" << endl;
 20:    cout << "remove(\"one\"): returns " << bag.remove("one")
 21:         << "; should be 0 (false)" << endl;
 22:    cout << endl;
 23:    
 24:    displayBag(bag);
 25:    
 26:    cout << "After clearing the bag, ";
 27:    bag.clear();
 28:    cout << "isEmpty: returns " << bag.isEmpty()
 29:         << "; should be 1 (true)" << endl;