You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

  1. #include "Element.hpp"
  2. int Element::WEAK_COMPATIBILITY = -1;
  3. int Element::NEUTRAL_COMPATIBILITY = 0;
  4. int Element::STRONG_COMPATIBILITY = 1;
  5. Element::Element(std::string elementName,
  6. Element *elementWeakAgainst,
  7. Element *elementStrongAgainst)
  8. : name(elementName),
  9. weakAgainst(elementWeakAgainst),
  10. strongAgainst(elementStrongAgainst)
  11. {
  12. }
  13. std::string Element::getName()
  14. {
  15. return this->name;
  16. }
  17. void Element::setStrongAgainst(Element *element)
  18. {
  19. this->strongAgainst = element;
  20. }
  21. void Element::setWeakAgainst(Element *element)
  22. {
  23. this->weakAgainst = element;
  24. }
  25. bool Element::isStrongAgainst(Element *element)
  26. {
  27. return this->strongAgainst == element;
  28. }
  29. bool Element::isWeakAgainst(Element *element)
  30. {
  31. return this->weakAgainst == element;
  32. }
  33. int Element::compatibilityAgainst(Element *element)
  34. {
  35. if (this->isStrongAgainst(element))
  36. {
  37. return Element::STRONG_COMPATIBILITY;
  38. }
  39. else if (this->isWeakAgainst(element))
  40. {
  41. return Element::WEAK_COMPATIBILITY;
  42. }
  43. else
  44. {
  45. return Element::NEUTRAL_COMPATIBILITY;
  46. }
  47. }
  48. bool Element::operator<(Element &element)
  49. {
  50. return this->name < element.name;
  51. }