diff --git a/exercice_2/src/main.cc b/exercice_2/src/main.cc index 0870608..49af90b 100644 --- a/exercice_2/src/main.cc +++ b/exercice_2/src/main.cc @@ -1,51 +1,51 @@ /* created by Marti Bosch and Marc Schwaerzel*/ /* -------------------------------------------------------------------------- */ #include +#include #include #include #include "compute_arithmetic.hh" #include "compute_pi.hh" #include "print_series.hh" #include "series.hh" + +using namespace std; /* -------------------------------------------------------------------------- */ int main(int argc, char **argv) { - std::cout << "exercice 2" << std::endl; - - /* std::cout << "please enter the following arguments: frequence, maxiter, " - "serie_type= #" - << std::endl; - const char *series_type; - int maxiter; - int ferquency; + cout << "exercice 2" << endl; + cout << "please enter the following arguments: serie_type(1=arithmetic, 2=pi), maxiter" << endl; - if (argc != 3) { +if (argc != 3) { - std::cout << "retry with arg: frequence, maxiter, serie_type=pi/arithmetic" + std::cout << "\nincorrect number of input arguments\n" << std::endl; return EXIT_FAILURE; } - Series *input_series_type; - if (series_type == "arithmetic"){ +int serie_type = atoi(argv[1]); +int N = atoi(argv[2]); - input_series_type = new ComputeArithmetic(); +Series* my_object; - } - else if (series_type == "pi"){ +if (serie_type == 1){ + my_object = new ComputeArithmetic(); + cout <<"I compute arithmetic"<< endl; + } +else if (serie_type == 2){ + my_object = new ComputePi(); + cout <<"\nI compute pi"<< endl; + } + +double res = my_object->compute(N); +cout << "result for test for ex 2.6:\t" << res <