// file: GcdClient.cpp
// object-oriented, pointer semantics

#include "PairWithGcdR.hpp"
#include "PairWithGcdI.hpp"
			
#include <cstdlib>
#include <iostream>

	static PairWithGcd * const pair_r = new PairWithGcdR();
	static PairWithGcd * const pair_i = new PairWithGcdI();
					
	int main (int argc, char * argv[]) 
	{
		if (argc < 3) 
		{
			std::cout << "Please call the gcd calculator with two integer arguments!";
		} 
		else 
		{
	        PairWithGcd * pair; 
			if (argc > 3 && tolower(*(argv[3])) == 'r')
			{
		 	   pair = pair_r;
			   std::cout << "recursive: ";
			}
			else
			{
		 	   pair = pair_i;
			   std::cout << "iterative: ";
			}
   			pair->set(std::atoi(argv[1]), std::atoi(argv[2]));
			std::cout << pair->gcd();
		}
		std::cout << std::endl;
		return 0;
	}
