//----------------------------------------------------------------------
//  SPECIFICATION FILE (person.h)
//  This module exports a record type for personal data and a class
//  for maintaining lists of such records
//----------------------------------------------------------------------
#include "bool.h"

struct PersonRec {
    char* name;        // Pointer to person's name
    int   age;         // Person's age
};

struct  PersonNode;     // Complete declaration hidden in
                        // implementation file
class PersonList {
public:
    Boolean IsEmpty() const;
        // POST: FCTVAL == (list is empty)

    Boolean IsFull() const;
        // POST: FCTVAL == (list is full)

    void Reset();
        // PRE:  NOT IsEmpty()
        // POST: List cursor is at front of list

    Boolean EndOfList() const;
        // POST: FCTVAL == (list cursor is beyond end of list)

    void Advance();
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: List cursor has advanced to next record

    PersonRec CurrentRec() const;
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: FCTVAL == record at list cursor

    void InsertBefore( /* in */ PersonRec someRec );
        // PRE:  Assigned(someRec)  &&  NOT IsFull()
        // POST: someRec inserted before list cursor
        //          (at back, if EndOfList())
        //    && This is the new current record

    void InsertAfter( /* in */ PersonRec someRec );
        // PRE:  Assigned(someRec)  &&  NOT IsEmpty()
        //    && NOT IsFull()  &&  NOT EndOfList()
        // POST: someRec inserted after list cursor
        //    && This is the new current record

    void Delete();
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: Record at list cursor deleted
        //    && Successor of deleted record is now the current record

    PersonList();
        // Constructor
        // POST: Empty list created  &&  EndOfList()

    ~PersonList();
        // Destructor
        // POST: List destroyed
private:
    PersonNode* head;
    PersonNode* currPtr;
};

