diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
| commit | 822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd (patch) | |
| tree | 40dc605213eff20f62b16e5f54e5e5e03d744d63 /pokemod/CoinListObject.cpp | |
| parent | 696414f1dc8bc419427efb6c1abe1bbae0a68a56 (diff) | |
[FIX] Exceptions no longer used in pokemod
[DEL] Exception and BugCatcher are no longer needed
[ADD] Object.cpp added
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@119 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/CoinListObject.cpp')
| -rw-r--r-- | pokemod/CoinListObject.cpp | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp index 499427a5..11b358f5 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -47,38 +47,12 @@ CoinListObject::CoinListObject(const QDomElement& xml, const Object* parent, con load(xml, id); } -bool CoinListObject::validate() const -{ - // TODO: validate -// bool valid = true; -// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Object with id %1---").arg(id()), Pokemod::V_Msg); -// if (Item == m_type) -// { -// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_object) == INT_MAX) -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item"); -// valid = false; -// } -// } -// else if (Species == m_type) -// { -// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_object) == INT_MAX) -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid Species"); -// valid = false; -// } -// } -// else -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type"); -// valid = false; -// } -// if (!m_amount || ((1 < m_amount) && (Species == m_type))) -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid amount"); -// valid = false; -// } -// return valid; +void CoinListObject::validate(QTextStream& stream) +{ + TEST_SETUP(); + TEST(setType, type); + TEST(setObject, object); + TEST(setAmount, amount); } void CoinListObject::load(const QDomElement& xml, int id) @@ -100,25 +74,34 @@ QDomElement CoinListObject::save() const return xml; } -void CoinListObject::setType(const int type) throw(BoundsException) +void CoinListObject::setType(const int type) { if (End <= type) - error<BoundsException>("type"); + { + boundsError("type"); + return; + } m_type = type; m_object = INT_MAX; } -void CoinListObject::setObject(const int object) throw(BoundsException) +void CoinListObject::setObject(const int object) { if (((Item == m_type) && (static_cast<const Pokemod*>(pokemod())->itemIndex(object) == INT_MAX)) || ((Species == m_type) && (static_cast<const Pokemod*>(pokemod())->speciesIndex(object) == INT_MAX))) - error<BoundsException>("object"); + { + boundsError("object"); + return; + } m_object = object; } -void CoinListObject::setAmount(const int amount) throw(BoundsException) +void CoinListObject::setAmount(const int amount) { if (!amount || ((Species == m_type) && (1 < amount))) - error<BoundsException>("amount"); + { + boundsError("amount"); + return; + } m_amount = amount; } |
