bool StringObject::less(IObject *obj) { StringObject *temp = dynamic_cast<StringObject*>(obj); if(this->equal(obj)) return false; int min = strlen(value); if((int)strlen(temp->getStr()) < min) min = strlen(temp->getStr()); char *checkThis = this->getStr(); char *checkObj = temp->getStr(); int count = 0; for(count = 0; count < min; ++count) { if(checkThis[count] > checkObj[count]) return false; else if(checkThis[count] < checkObj[count]) return true; } if(count == (int)strlen(value)) return true; else return false; }
bool StringObject::equal(IObject *obj) { StringObject *temp = dynamic_cast<StringObject*>(obj); if((strcmp(this->value, temp->getStr())) == 0) return true; else return false; }