1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: template<class ItemType>
5: ItemType ArrayList<ItemType>::getEntry(int position) const throw(PrecondViolatedExcept)
6: {
7: // Enforce precondition
8: bool ableToGet = (position >= 1) && (position <= itemCount);
9: if (ableToGet)
10: return items[position];
11: else
12: {
13: std::string message = "getEntry() called with an empty list or ";
14: message = message + "invalid position.";
15: throw(PrecondViolatedExcept(message));
16: } // end if
17: } // end getEntry