#include #include #include "exception.h" #include "obstacle.h" #include "parse.h" using namespace JFK; using std::string; obstacle::obstacle(int itype) : type(itype) { } string obstacle::tostring() const { std::ostringstream oss; oss << "x=" << x << " y=" << y << " type=" << type; return oss.str(); } void obstacle::fromstring(const string& s) { int index = 0; string arg = argument(0, s); while (arg.length() > 0) { string id = identifier(arg); if (id == "x") x = strtodbl(value(arg)); else if (id == "y") y = strtodbl(value(arg)); else if (id == "type") type = strtoint(value(arg)); //else throw exception("wrong string"); better ignore... index++; arg = argument(index, s); } } string obstacle::classname() const { return "obstacle"; }