#include "program.hh" #include "time_io.hh" #include "options.hh" #include #include #include #include #include #include #include #include int number_of_args(std::string program) { if (program == "helloworld") { return 0; } else if (program == "faculty") { return 1; } else { std::cerr << "Unknown program: " << program << std::endl; exit(EXIT_FAILURE); } } void run_program (std::string program, std::string** program_args) { if (program == "helloworld") { helloworld(); } else if (program == "faculty") { int highest = atoi(program_args[0]->c_str()); faculty(highest); } else { std::cerr << "Can't find program: " << program << std::endl; exit(EXIT_FAILURE); } } void helloworld() { if (!really_quiet) { std::cout << "Hello, world!" << std::endl; } } void faculty(int highest) { static int current = 0; static int sum = 1; bool news = true; switch (current) { case 0: { current = highest; sum = 1; break; } case 1: { news = false; break; } default: { sum *= current--; break; } } if (news and !really_quiet) { std::cout << "Faculty is now: " << sum << std::endl; } }