/**
   * Appends the specified person to the end of this register.
   *
   * @param person person to append to this register
   */
  public void addPerson(Person person) throws Exception {

    for (int i = 0; i < count; i++) {
      if (person.getName().equals(persons[i].getName())
          || person.getPhoneNumber().equals(persons[i].getPhoneNumber())) {
        throw new Exception(
            "Person with this name or telephone number already exist in register.\n"
                + "Name and telephone number must be unique. ");
      }
    }
    persons[count] = person;
    count++;
    Arrays.sort(persons, 0, count);
  }
  /**
   * Removes the specified person from the register.
   *
   * @param person person to remove
   */
  public void removePerson(Person person) throws Exception {

    for (int i = 0; i < count; i++) {

      if (person.equals(getPerson(i))) {
        --count;
        for (; i < count; ++i) {
          persons[i] = persons[i + 1];
        }
        return;
      }
    }
    throw new Exception("This person does not exist in register.");
  }