diff --git a/Homework2/src/main.cc b/Homework2/src/main.cc index 2c75031..6a35f7c 100644 --- a/Homework2/src/main.cc +++ b/Homework2/src/main.cc @@ -1,88 +1,91 @@ #include #include #include "series.hh" #include "compute_arithmetic.hh" #include "compute_pi.hh" #include "dumper_series.hh" #include "print_series.hh" using namespace std; -void decide_series(Series *&new_series, string type) -{ - if (type == "arithmetic") - { - new_series = new compute_arithmetic(); - } - else if (type == "pi") - { - new_series = new compute_pi(); - } - else - { - cout<<"ERROR: Invalid series type. Please enter 'arithmetic' or 'pi'."<compute(10) << endl; //Arithmetic series up to 10. Expected value: 55 cout << SERIES2->compute(10) << endl; //Pi series up to 10. Expected value: 3.04936 delete SERIES1; //Free up memory delete SERIES2; //Free up memory */ std::string serie_type = argv[1]; std::string dump_type = argv[2]; unsigned long N = atof (argv[3]); // max number of iteration entered as input unsigned long freq = atof(argv[4]); //frequency for dumper series Series *ptrSeries = nullptr; // Choose series to be implemented decide_series(ptrSeries, serie_type); // Dumper and writing if (dump_type == "write") { PrintSeries my_dump(*ptrSeries, N, freq); my_dump.dump(); } else if (dump_type == "plot") { std::cout << "Dump type not implemented yet" << std::endl; abort(); } else { std::cout << "Dump type does not exist" << std::endl; abort(); } delete ptrSeries; return 0; } + +void decide_series(Series *&new_series, string type) +{ + if (type == "arithmetic") + { + new_series = new compute_arithmetic(); + } + else if (type == "pi") + { + new_series = new compute_pi(); + } + else + { + cout<<"ERROR: Invalid series type. Please enter 'arithmetic' or 'pi'."<