Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
override and virtual destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shikanime committed Feb 5, 2018
1 parent 0cafad7 commit 8f9a8ba
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 414 deletions.
74 changes: 37 additions & 37 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"files.associations": {
"cmath": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory0": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp"
}
{
"files.associations": {
"cmath": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory0": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp"
}
}
2 changes: 1 addition & 1 deletion Carrier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Carrier : public Unit
{
public:
UnitField getField(void) const noexcept;
UnitField getField(void) override const noexcept;
};

#endif
290 changes: 145 additions & 145 deletions CellProperty.cpp
Original file line number Diff line number Diff line change
@@ -1,146 +1,146 @@
#include "CellProperty.hh"

CellProperty::CellProperty(const bool walkable, const bool swimmable, const bool flyable, const bool event, const bool monster) noexcept
: _walkable(walkable), _swimmable(swimmable), _flyable(flyable), _event(event), _monster(monster)
{
}

CellProperty::CellProperty(const CellType cell) noexcept
{
switch (cell) {
case CellType::GrassCell:
CellProperty(true, false, true, false, false);
break;
case CellType::WaterCell:
CellProperty(false, true, true, false, false);
break;
case CellType::RockCell:
CellProperty(false, false, true, false, false);
break;
case CellType::MountainCell:
default:
CellProperty(false, false, false, false, false);
break;
}
}

bool CellProperty::operator==(CellProperty property) const noexcept
{
return this->isEqual(property);
}

bool CellProperty::operator!=(CellProperty property) const noexcept
{
return !this->isEqual(property);
}

bool CellProperty::isEqual(const CellProperty property) const noexcept
{
return (this->isWalkable() == property.isWalkable()) &&
(this->isSwimmable() == property.isSwimmable()) &&
(this->isFlyable() == property.isFlyable()) &&
(this->isEvent() == property.isEvent()) &&
(this->isMonster() == property.isMonster());
}

bool CellProperty::isWalkable(void) const noexcept
{
return _walkable;
}

void CellProperty::setWalkable(void) noexcept
{
this->_walkable = true;
}

void CellProperty::setNotWalkable(void) noexcept
{
this->_walkable = false;
}

bool CellProperty::isSwimmable(void) const noexcept
{
return this->_swimmable;
}

void CellProperty::setSwimmable(void) noexcept
{
this->_swimmable = true;
}

void CellProperty::setNotSwimmable(void) noexcept
{
this->_swimmable = false;
}

bool CellProperty::isFlyable(void) const noexcept
{
return this->_flyable;
}

void CellProperty::setFlyable(void) noexcept
{
this->_flyable = true;
}

void CellProperty::setNotFlyable(void) noexcept
{
this->_flyable = false;
}

bool CellProperty::isEvent(void) const noexcept
{
return this->_event;
}

void CellProperty::setEvent(void) noexcept
{
this->_event = true;
}

void CellProperty::setNotEvent(void) noexcept
{
this->_event = false;
}

bool CellProperty::isMonster(void) const noexcept
{
return _monster;
}

void CellProperty::setMonster(void) noexcept
{
this->_monster = true;
}

void CellProperty::setNotMonster(void) noexcept
{
this->_monster = false;
}

CellProperty getCellFlags(const CellType cell) noexcept
{
switch (cell) {
case CellType::GrassCell:
return CellProperty(true, false, true, false, false);
case CellType::WaterCell:
return CellProperty(false, true, true, false, false);
case CellType::RockCell:
return CellProperty(false, false, true, false, false);
case CellType::MountainCell:
return CellProperty(false, false, false, false, false);
default:
return CellProperty(false, false, false, false, false);
}
}

bool hasFlag(CellType cell, CellProperty property) noexcept
{
CellProperty cellProperty(getCellFlags(cell));

return (cellProperty.isWalkable() == property.isWalkable()) ||
(cellProperty.isSwimmable() == property.isSwimmable()) ||
(cellProperty.isFlyable() == property.isFlyable()) ||
(cellProperty.isEvent() == property.isEvent()) ||
(cellProperty.isMonster() == property.isMonster());
#include "CellProperty.hh"

CellProperty::CellProperty(const bool walkable, const bool swimmable, const bool flyable, const bool event, const bool monster) noexcept
: _walkable(walkable), _swimmable(swimmable), _flyable(flyable), _event(event), _monster(monster)
{
}

CellProperty::CellProperty(const CellType cell) noexcept
{
switch (cell) {
case CellType::GrassCell:
CellProperty(true, false, true, false, false);
break;
case CellType::WaterCell:
CellProperty(false, true, true, false, false);
break;
case CellType::RockCell:
CellProperty(false, false, true, false, false);
break;
case CellType::MountainCell:
default:
CellProperty(false, false, false, false, false);
break;
}
}

bool CellProperty::operator==(CellProperty property) const noexcept
{
return this->isEqual(property);
}

bool CellProperty::operator!=(CellProperty property) const noexcept
{
return !this->isEqual(property);
}

bool CellProperty::isEqual(const CellProperty property) const noexcept
{
return (this->isWalkable() == property.isWalkable()) &&
(this->isSwimmable() == property.isSwimmable()) &&
(this->isFlyable() == property.isFlyable()) &&
(this->isEvent() == property.isEvent()) &&
(this->isMonster() == property.isMonster());
}

bool CellProperty::isWalkable(void) const noexcept
{
return _walkable;
}

void CellProperty::setWalkable(void) noexcept
{
this->_walkable = true;
}

void CellProperty::setNotWalkable(void) noexcept
{
this->_walkable = false;
}

bool CellProperty::isSwimmable(void) const noexcept
{
return this->_swimmable;
}

void CellProperty::setSwimmable(void) noexcept
{
this->_swimmable = true;
}

void CellProperty::setNotSwimmable(void) noexcept
{
this->_swimmable = false;
}

bool CellProperty::isFlyable(void) const noexcept
{
return this->_flyable;
}

void CellProperty::setFlyable(void) noexcept
{
this->_flyable = true;
}

void CellProperty::setNotFlyable(void) noexcept
{
this->_flyable = false;
}

bool CellProperty::isEvent(void) const noexcept
{
return this->_event;
}

void CellProperty::setEvent(void) noexcept
{
this->_event = true;
}

void CellProperty::setNotEvent(void) noexcept
{
this->_event = false;
}

bool CellProperty::isMonster(void) const noexcept
{
return _monster;
}

void CellProperty::setMonster(void) noexcept
{
this->_monster = true;
}

void CellProperty::setNotMonster(void) noexcept
{
this->_monster = false;
}

CellProperty getCellFlags(const CellType cell) noexcept
{
switch (cell) {
case CellType::GrassCell:
return CellProperty(true, false, true, false, false);
case CellType::WaterCell:
return CellProperty(false, true, true, false, false);
case CellType::RockCell:
return CellProperty(false, false, true, false, false);
case CellType::MountainCell:
return CellProperty(false, false, false, false, false);
default:
return CellProperty(false, false, false, false, false);
}
}

bool hasFlag(CellType cell, CellProperty property) noexcept
{
CellProperty cellProperty(getCellFlags(cell));

return (cellProperty.isWalkable() == property.isWalkable()) ||
(cellProperty.isSwimmable() == property.isSwimmable()) ||
(cellProperty.isFlyable() == property.isFlyable()) ||
(cellProperty.isEvent() == property.isEvent()) ||
(cellProperty.isMonster() == property.isMonster());
}
Loading

0 comments on commit 8f9a8ba

Please sign in to comment.