////////////////////////////////////////////////////////////////////////
//
//  Specification file for the StrList class.
//
//  Note: No function should print an error message.
//
//
#include "bool.h"

struct Node;
const int MAX_LENGTH = 30;

class StrList
{
  public:

    /////////////////////////////////////////////////////////////////////
    //  Constructor (default)
    //
    //  Creates an empty list.
    //
    //   Inputs: None
    //
    //  Outputs: None
    //
    StrList(void);

    /////////////////////////////////////////////////////////////////////
    //  Function: Prepend
    //
    //  Adds an item at the head of the list. If the item to be prepended
    //  is NULL, it doesn't get added. No error message is printed. If
    //  the item is larger than MAX_LENGTH, it is truncated to fit.
    //
    //   Inputs: item - a NULL terminated string.
    //
    //  Outputs: None.
    //
    void Prepend(const char *item);

    /////////////////////////////////////////////////////////////////////
    //  Function: Display
    //
    //  Prints each item in the list to the screen. After the entire
    //  list has been printed, a new line is printed.
    //  
    //   Inputs: separateLine - A Boolean that determines the format
    //           of the output as follows:
    //
    //            TRUE - Each item is printed on its own line.
    //           FALSE - All items are printed on the same line; they
    //                   are separated by a single space.
    //
    //  Outputs: None
    //
    void Display(Boolean separateLine = TRUE) const;

    /////////////////////////////////////////////////////////////////////
    //  Function: getCount
    //
    //  Returns the number of items in the list.
    //
    //   Inputs: None
    //
    //  Outputs: The number of items in the list.
    //
    int getCount(void) const;

    /////////////////////////////////////////////////////////////////////
    //  Function: isEmpty
    //
    //  Returns a Boolean indicating whether or not the list is empty.
    //
    //   Inputs: None
    //
    //  Outputs: A Boolean value that means:
    //            TRUE - The list is empty
    //           FALSE - The list is NOT empty
    //
    Boolean isEmpty(void) const;

    /////////////////////////////////////////////////////////////////////
    //  Destructor
    //
    //  Deletes all items in the list.
    //
    //   Inputs: None
    //
    //  Outputs: None
    //
    ~StrList(void);

    /////////////////////////////////////////////////////////////////////
    //  Function: Append
    //
    //  Adds an item to the end of the list. If the item to be appended
    //  is NULL, nothing gets added. No error message is printed. If the
    //  item is larger than MAX_LENGTH, it is truncated to fit.
    //
    //   Inputs: item - a NULL terminated string to be added
    //
    //  Outputs: None
    //
    void Append(const char *item);

    /////////////////////////////////////////////////////////////////////
    //  Function: isPresent
    //
    //  Determines whether or not a particular item is in the list. If
    //  the item to be found is NULL, the function returns FALSE.
    //
    //   Inputs: item - a NULL terminated string that will be searched
    //                  for.
    //
    //  Outputs: A Boolean value meaning:
    //            TRUE - the item is in the list
    //           FALSE - the item is NOT in the list
    //
    Boolean isPresent(const char *item) const;

    /////////////////////////////////////////////////////////////////////
    //  Function: getItem
    //
    //  Returns the string at the given position in the list. If the 
    //  value of position is larger than the list or less than 1, the 
    //  return value is NULL.
    //
    //   Inputs: position - an integer that represents a position in the
    //           the list
    //
    //  Outputs: A pointer to the string in the list or NULL if position
    //           is invalid
    //
    const char* getItem(int position) const;

    /////////////////////////////////////////////////////////////////////
    //  Function: Remove
    //
    //  Removes an item from the list. If the item is in the list, it is
    //  removed. If the item is not in the list, nothing happens and 
    //  there is NO error message. If there is more than one occurrence
    //  of the item, ONLY the first occurrence is removed.
    //
    //   Inputs: item - a NULL terminated string that is searched for in
    //           the list.
    //
    //  Outputs: None.
    //
    void Remove(const char *item);

  private:
    Node* head;
};
