28 if (str.
length() > maxLength) {
29 return str.
substr(0, maxLength - 1) +
".";
40void PhoneBook::displaySavedContacts()
const {
46 for (
int i = 0; i < contactCount_; ++i) {
47 std::string firstName = truncateString(contacts_[i].getFirstName(), 10);
48 std::string lastName = truncateString(contacts_[i].getLastName(), 10);
49 std::string nickName = truncateString(contacts_[i].getNickName(), 10);
64bool PhoneBook::getValidIndex(
int &index)
const {
69 if (!(iss >> index)) {
73 if (index >= 1 && index <= contactCount_) {
75 if (iss >> remaining) {
93void PhoneBook::displayContactInfo(
const Contact &contact)
const {
108 if (contactCount_ < 1) {
113 displaySavedContacts();
116 if (getValidIndex(index) !=
true)
118 displayContactInfo(contacts_[index - 1]);
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
basic_string substr(size_type __pos=0, size_type __n=npos) const
size_type length() const noexcept
bool empty() const noexcept
std::string getInputLine() const
Reads a line of text from standard input.
void searchContact() const
Searches for and displays contact information by index