X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=agents%2Fc%2B%2B%2Fmain.cpp;fp=agents%2Fc%2B%2B%2Fmain.cpp;h=d0d7d4a3a62bcc5ed8f1777050b7e1b66c3a8d90;hp=0000000000000000000000000000000000000000;hb=159708785516e4dd5a1ddceadd1e371f48dd3d23;hpb=c2fbd2e5499e4817c156f9dbabea5215d83729dd diff --git a/agents/c++/main.cpp b/agents/c++/main.cpp new file mode 100644 index 0000000..d0d7d4a --- /dev/null +++ b/agents/c++/main.cpp @@ -0,0 +1,38 @@ +/** + * agent++ : A Sample agent for UCC::Progcomp2013 + * @file main.cpp + * @purpose The main function + */ +#include +#include +#include + +#include "agent.h" // Declarations for agent, see also agent.cpp + +using namespace std; + +/** + * @funct main + * @purpose The main function; starts the agent + * @param argc - Number of arguments, unused + * @param argv - Argument string array, unused + */ +int main(int argc, char ** argv) +{ + srand(time(NULL)); // seed random number generator + + string colour; cin >> colour; // first read the colour of the agent + + try + { + Agent agent(colour); // create an agent using the colour + agent.Run(cin, cout); // run the agent (it will read from cin and output to cout) + } + catch (const Exception & e) + { + return 1; + } + + + return 0; // Don't use exit(3), because it causes memory leaks in the C++ stdlib +}