|
|
- #include "Element.hpp"
-
- int Element::WEAK_COMPATIBILITY = -1;
- int Element::NEUTRAL_COMPATIBILITY = 0;
- int Element::STRONG_COMPATIBILITY = 1;
-
- Element::Element(std::string elementName,
- Element *elementWeakAgainst,
- Element *elementStrongAgainst)
- : name(elementName),
- weakAgainst(elementWeakAgainst),
- strongAgainst(elementStrongAgainst)
- {
- }
-
- std::string Element::getName()
- {
- return this->name;
- }
-
- void Element::setStrongAgainst(Element *element)
- {
- this->strongAgainst = element;
- }
-
- void Element::setWeakAgainst(Element *element)
- {
- this->weakAgainst = element;
- }
-
- bool Element::isStrongAgainst(Element *element)
- {
- return this->strongAgainst == element;
- }
-
- bool Element::isWeakAgainst(Element *element)
- {
- return this->weakAgainst == element;
- }
-
- int Element::compatibilityAgainst(Element *element)
- {
- if (this->isStrongAgainst(element))
- {
- return Element::STRONG_COMPATIBILITY;
- }
- else if (this->isWeakAgainst(element))
- {
- return Element::WEAK_COMPATIBILITY;
- }
- else
- {
- return Element::NEUTRAL_COMPATIBILITY;
- }
- }
-
- bool Element::operator<(Element &element)
- {
- return this->name < element.name;
- }
|