/* This file presents the interface for the RandomInt class,
     a class that provides a RandomInt data type, as well as
     convenient operations on RandomInt objects.

   Written by: Joel C. Adams, Spring, 1993, at Calvin College.
-------------------------------------------------------------*/

#ifndef RANDOMINT
#define RANDOMINT

#include <iostream.h>
#include <stdlib.h>

class RandomInt
{
   int
      LowerBound,             // the lower limit on random values
      UpperBound,             // the upper limit on random values
      RandomValue;            // the actual value chosen

  public:

  /*--- This is the class constructor for class RandomInt.

     Precondition:  A RandomInt object has been declared.
     Receive:       Low, the lower bound of the range of random values;
                    High, the upper bound of the range of random values.
     Postcondition: That object's members are initialized.
  ---------------------------------------------------------------------*/

  RandomInt(int Low = 0, int High = RAND_MAX);

  /*--- This function converts a RandomInt to an integer,
          whenever its context is appropriate.

     Return: The RandomValue member of this object.
  ---------------------------------------------------------------------*/

  operator int() {return RandomValue;}

  /*--- This function generates the next random number.

     Receive: Low, an optional lower bound on the range of random values;
              High, an optional upper bound on the range of random values
           (if Low and High are omitted, the constructed values are used).
     Return:  This object, its RandomValue member set to a random
                number from the range Low..High.
  ---------------------------------------------------------------------*/

  RandomInt Generate(int Low = 0, int High = 0);

  /*--- This is the assignment operator for a RandomInt.

     Receive: A RandomInt object, RInt.
     Return:  This RandomInt object, its members identical to those
                of RInt.
  ---------------------------------------------------------------------*/

  RandomInt& operator=(const RandomInt& RInt);

  /*--- This function performs the output operation for a RandomInt.

     Recieve: An ostream and a RandomInt.
     Output:  The RandomInt onto the ostream.
     Return:  The ostream.
  ---------------------------------------------------------------------*/

  friend ostream& operator<<(ostream& Out, const RandomInt& RInt);
};

#endif

