/*****************************************************************************
 Demo for the template class 'V' as an interface to 'Vec' and 'sumVec'

 The program asks the user for a sequence of Vec's or sumVec's. It stores them 
 in a vector, then displays them.

 Note the simplified access to dynamic binding provided by 'V'.
 * **************************************************************************/
#include<iostream>
#include<iomanip>
#include "sumVec.h"
#include <vector>
#include<string>
#include<cctype>


using std::cin; using std::cout;
using std::endl; using std::vector;
using std::string; using std::tolower;

void load_V(V<int>& v)
{
	cout<<"\nPlease enter values or a non-number to stop.\n";
	int temp;
		while(cin>>temp)
			v.push_back(temp);
		cin.clear();
}
	



int main()

{
	vector<V<int> > vectors;
	string kind="w", trash;
	while(kind[0]=='s' || kind[0]=='w')
	{
		cout<<endl;
		cout<<"Please enter 's' for a vector with a sum,\n'w' for a "<<
		       	"vector without a sum, or 'q' to quit: ";
		cin>>kind;
		/* We can push_back into V's made with the 0-parameter 
		 * constructor, but the 2 or 3 parameter constructor 
		 * gives smooth access to a Vec or sumVec.
		 */
		if(tolower(kind[0]=='s'))
		{
				V<int> temp(0,0,1);//gives an empty sumVec.
				load_V(temp);
				vectors.push_back(temp);
				cin>>trash;
				
		}
		else if(tolower(kind[0]=='w'))
		{
				V<int> temp(0,0);//gives an empty Vec.
				load_V(temp);
				vectors.push_back(temp);
				cin>>trash;
				
		}
		
	}
	cout<<endl<<endl<<"The vectors, with sums if applicable:\n";
	for(vector<V<int> >::size_type i=0; i!=vectors.size();i++)
	{
		vectors[i].show();
		cout<<endl;
	}
		
				
		

	return 0;
}

	
