diff --git a/homework2/src/main.cc b/homework2/src/main.cc index 869b260..66fdf41 100644 --- a/homework2/src/main.cc +++ b/homework2/src/main.cc @@ -1,19 +1,44 @@ //main #include "ComputeArithmetic.hh" #include "ComputePi.hh" #include +#include using namespace std; -int main(){ +int main(int argc, char ** argv){ - unsigned N=500; + //command line arguments: Type of series and N of terms. - ComputePi my_serie; - double tmp = my_serie.compute(N); + stringstream sstr; + for (int i = 1 ; i < argc ; ++i){ + sstr << argv[i] << " "; + } - cout<<"Result for the arithmetic series with "<> which_series; + sstr >> N; + Series * my_series = NULL; + + if (which_series == "pi") + my_series = new ComputePi(); + else if (which_series == "arithmetic") + my_series = new ComputeArithmetic(); + else { + cout<<"insert one of the two available options:" + "\n\t arithmetic (to compute arithmetic series)" + "\n\t pi (to compute Pi series)"<compute(N); + + cout<<"Result for the "<