//Programmer: Bo Bayles  Date: 26 October 2004
//File: plot.cpp         Class: CS54 C
//Purpose: This is the implementation file for the functions that will
//  get random numbers, then plot them on the screen.

#include "plot.h"
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;

void fillArray(int NumArray[], const int iNumPlot, const int iMin, const int iMax)
{
  for(int i = 0; i < iNumPlot; i++)
  {
    NumArray[i] = getRand(iMin, iMax);
  }
  return;
}
//Fill each element of the array with a random number by calling getRand.

int getRand(const int iMin, const int iMax)
{
  int iRandomInt = 0;

  iRandomInt = iMin + (rand() % iMax);

  return iRandomInt;
}
//Generate a random number with rand, then return it to the calling function.

void plotArray (const int iNumArray[], const int iNumPlot)
{
  for(int i = 0; i < iNumPlot; i++)
  {
    cout << "|";
    cout << setw(iNumArray[i]);
    cout.setf(ios::right);
    cout << "*" << endl;
  }
  cout << "__________________________________________________________________"
       << endl
       << "0    5   10   15   20   25   30   35   40   45   50   55   60   65";

  return;
}
//Output a | for the vertical axis, set the width to the value in the array with
//  setw, then output a right-justified *. Then the horizontal axis.

