FILE: list1.h
// CLASS PROVIDED: List (a container class for a List of items,
// where each List may have a designated item called the current item)
//
// TYPEDEF and MEMBER CONSTANTS for the List class:
// static const size_t CAPACITY = ____
// List::CAPACITY is the maximum number of items that a List can hold.
//
// typedef ____ Item
// List::Item is the data type of the items in the List. It may be any
of
// the C++ built-in types (int, char, etc.), or a class with a default
// constructor, an assignment operator, and a copy constructor.
//
// CONSTRUCTOR for the List class:
// List( )
// Postcondition: The List has been initialized as an empty List.
//
// MODIFICATION MEMBER FUNCTIONS for the List class:
// void start( )
// Postcondition: The first item on the List becomes the current item
// (but if the List is empty, then there is no current item).
//
// void advance( )
// Precondition: is_item returns true.
// Postcondition: If the current item was already the last item on the
// List, then there is no longer any current item. Otherwise, the new
// current item is the item immediately after the original current item.
//
// void insert(const Item& entry)
// Precondition: size( ) < CAPACITY.
// Postcondition: A new copy of entry has been inserted in the List before
// the current item. If there was no current item, then the new entry
has
// been inserted at the front of the List. In either case, the newly
// inserted item is now the current item of the List.
//
// void attach(const Item& entry)
// Precondition: size( ) < CAPACITY.
// Postcondition: A new copy of entry has been inserted in the List after
// the current item. If there was no current item, then the new entry
has
// been attached to the end of the List. In either case, the newly
// inserted item is now the current item of the List.
//
// void remove_current( )
// Precondition: is_item returns true.
// Postcondition: The current item has been removed from the List, and
the
// item after this (if there is one) is now the new current item.
//
// CONSTANT MEMBER FUNCTIONS for the List class:
// size_t size( ) const
// Postcondition: The return value is the number of items on the List.
//
// bool is_item( ) const
// Postcondition: A true return value indicates that there is a valid
// "current" item that may be retrieved by activating the current
// member function (listed below). A false return value indicates that
// there is no valid current item.
//
// Item current( ) const
// Precondition: is_item( ) returns true.
// Postcondition: The item returned is the current item on the List.
//
// VALUE SEMANTICS for the List class:
// Assignments and the copy constructor may be used with List objects.

#ifndef LIST1_H
#define LIST1_H
#include <stdlib.h> // Provides size_t

class List
{
public:
// TYPEDEF and MEMBER CONSTANTS
enum { CAPACITY = 30 }; // Or: static const size_t CAPACITY = 30;
typedef double Item;
// CONSTRUCTOR
List( );
// MODIFICATION MEMBER FUNCTIONS
void start( );
void advance( );
void insert(const Item& entry);
void attach(const Item& entry);
void remove_current( );
// CONSTANT MEMBER FUNCTIONS
size_t size( ) const;
bool is_item( ) const;
Item current( ) const;
private:
Item data[CAPACITY];
size_t used;
size_t current_index;
};

#endif