/*----
  signature: main: void -> int
  purpose: to try out the C++ vector class

  by: Sharon Tuttle 
  last modified: 2022-10-18
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    cout << boolalpha;

    vector<int> worm_counts;
    vector<double> worm_weights;
    vector<string> worm_names;

    // when vector's constructor is called with
    //    no arguments, you get an empty vector:

    cout << "worm_counts size: "
         << worm_counts.size() << endl;

    // to add a new element to the end of a vector
    //    and increase its size by 1, call
    //    push_back

    worm_weights.push_back(6.6);

    cout << "after push_back of 6.6, " << endl
         << "   worm_weights.size(): "
         << worm_weights.size() << endl
         << "   worm_weights[0]:     "
         << worm_weights[0] << endl;

    cout << "Enter number of remaining worm weights: ";

    int remaining_quant;
    cin >> remaining_quant;

    double next_weight;

    for (int i=1; i <= remaining_quant; i++)
    {
        cout << "enter next weight: ";
        cin >> next_weight;

        worm_weights.push_back(next_weight);
    }

    // now what is in worm_weights?

    cout << endl;
    cout << "vector worm_weights now contains: "
         << endl;

    for (int i=0; i < worm_weights.size(); i++)
    {
        cout << worm_weights[i] << endl;
    }

    vector<double> grades(47);

    cout << "grades.size(): "
         << grades.size() << endl;

    vector<string> destinations(4, "TBA");

    cout << "destinations.size(): "
         << destinations.size() << endl;

    for (int i=0; i < destinations.size(); i++)
    {
        cout << destinations[i] << endl;
    }

    // remove the last element of worm_weights

    worm_weights.pop_back();

    cout << endl;
    cout << "after call worm_weights.pop_back: "
         << endl;
    cout << "   worm_weights.size(): "
         << worm_weights.size() << endl;
    cout << "and its contents:" << endl;

    for (int i=0; i < worm_weights.size(); i++)
    {
        cout << worm_weights[i] << endl;
    }

    return EXIT_SUCCESS;
}