#include #include #include "exception.h" #include "item.h" #include "parse.h" using namespace JFK; using std::string; item::item(int itype) : type(itype) { r = 5.0; } string item::tostring() const { std::ostringstream oss; oss << "x=" << x << " y=" << y << " type=" << type; return oss.str(); } void item::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"); ignore better... index++; arg = argument(index, s); } } string item::classname() const { return "item"; }