//Programmer: Bo Bayles  Date: 26 October 2004
//File: lab10.cpp        Class: CS54 C
//Purpose: This program asks the user for the number of numbers to plot,
//  generates that many random numbers, and then plots them to the screen.

#include "plot.h"
#include "selSort.h"
#include <ctime>
#include <iostream>
using namespace std;
//Include the necessary libraries and headers..

int main()
{
  int iNumPlot = 0;
  const int iMin = 1;
  const int iMax = 65;
  int NumArray[20] = {0};
  char cContinue;
  //Declare variables for the number to plot, max and min, the array that's
  //  going to be used, and something to get the user's continuance choice.

  srand(time(NULL));
  //Seed the randomizer.

  cout << endl << "I'm the Random Number Plotter." << endl;

  do
  {
    do
    {
      cout << endl << "How many numbers should I plot? (1-20): ";
      cin >> iNumPlot;

      if(iNumPlot <= 0 || iNumPlot > 20)
        cout << "Invalid entry." << endl;
    }
    while(iNumPlot <= 0 || iNumPlot > 20);
    //Ask until the user enters a valid number.

  fillArray(NumArray, iNumPlot, iMin, iMax);
  //Call fillArray to fill the array with random numbers up to the user's choice.
  selSort(NumArray, iNumPlot);
  //Call selSort to sort the array in descending order.
  plotArray(NumArray, iNumPlot);
  //Call plotArray to plot the numbers to the screen.

  cout << endl << "Pretty cool, huh? Should I plot again? (y/n): ";
  cin >> cContinue;
  }
  while((cContinue != 'N') && (cContinue != 'n'));
  //Loop until the user wants to quit.

  cout << endl << "Exiting..." << endl;
  return 0;
}

