本文整理汇总了C++中Money类的典型用法代码示例。如果您正苦于以下问题:C++ Money类的具体用法?C++ Money怎么用?C++ Money使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Money类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _inspectExtraException
/**
* @brief StatUtil::_inspectExtraException
* 重新计算指定科目的余额,并检测其余额是否异常
* 异常的余额:正向记账科目,余额方向为贷,反向记账科目,余额方向为借
* @param fsub
* @param ssub
* @param mt
*/
void StatUtil::_inspectExtraException(BusiAction* ba)
{
FirstSubject* fsub = ba->getFirstSubject();
SecondSubject* ssub = ba->getSecondSubject();
Money* mt = ba->getMt();
int key_f = fsub->getId() * 10 + mt->code();
int key_s = ssub->getId() * 10 + mt->code();
bool r = false;
if(fsub->getJdDir()){ //正向记账科目
//余额方向必须在借方,且余额必须大于0
if((endFDir.value(key_f) == MDIR_D && endFExa.value(key_f) > 0.0) ||
(endFDir.value(key_f) == MDIR_J && endFExa.value(key_f) < 0.0))
r = true;
if((endSDir.value(key_s) == MDIR_D && endSExa.value(key_s) > 0.0) ||
(endSDir.value(key_s) == MDIR_J && endSExa.value(key_s) < 0.0))
r = true;
}
else{
//余额必须在贷方,且余额值必须大于0
if((endFDir.value(key_f) == MDIR_J && endFExa.value(key_f) > 0.0) ||
(endFDir.value(key_f) == MDIR_D && endFExa.value(key_f) < 0.0))
r = true;
if((endSDir.value(key_s) == MDIR_J && endSExa.value(key_s) > 0.0) ||
(endSDir.value(key_s) == MDIR_D && endSExa.value(key_s) < 0.0))
r = true;
}
if(r)
emit extraException(ba,endFExa.value(key_f), endFDir.value(key_f),endSExa.value(key_s),endSDir.value(key_s));
}
示例2:
void Money::operator =(Money Cash)
{
this->wasBelowZero=Cash.getWasBelowZero();
this->wasZeroFirst=Cash.getWasZero();
this->gold=Cash.gold;
this->penny=Cash.penny;
}
示例3: switch
//------------------------------------------------------------------------------
void ConditionValueDelegate::setModelData(QWidget* editor,
QAbstractItemModel* model, const QModelIndex& index) const
{
switch (field(index))
{
case AssignmentRule::Date:
{
QDateEdit* dateEditor = static_cast<QDateEdit*>(editor);
QDate date = dateEditor->date();
model->setData(index, date.toString(Qt::ISODate), Qt::EditRole);
}
break;
case AssignmentRule::Amount:
{
MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor);
Money amount = moneyEditor->value();
QString newVal = QString("%1,%2")
.arg(amount.amount()).arg(amount.currency().code());
model->setData(index, newVal, Qt::EditRole);
}
break;
default:
{
LineEdit* stringEditor = static_cast<LineEdit*>(editor);
model->setData(index, stringEditor->text(), Qt::EditRole);
}
}
}
示例4:
//
// ------ (/) operator ---
//
Money Money::operator/(double value) const
{
Money temp;
if (value != 0)
temp.amount(amount() / value);
return temp;
}
示例5: Money
Money operator+(const Money& l,const Money& r)
{
// std::cout << "left cents: " << l.get_cents() << '\n';
// std::cout << "right cents: " << r.get_cents() << '\n';
// std::cout << "left + right: " << l.get_cents() + r.get_cents() << '\n';
return Money(l.get_money_in_cents() + r.get_money_in_cents());
}
示例6: CollisionMoneyIndie
void CollisionMoneyIndie(iCollidable& _money, iCollidable& _indie)
{
Money* money = dynamic_cast<Money*>(&_money);
Indie* indie = dynamic_cast<Indie*>(&_indie);
money->markMeForDeletion();
Vector2 formerSize = indie->GetSize();
//indie->SetSize(formerSize.X * 2, formerSize.Y * 2);
}
示例7: TEST
TEST(ExpressionTest, PlusReturnSum) {
Money* five = Money::dollar(5);
Expression* result = five->plus(five);
Sum* sum = dynamic_cast<Sum*>(result);
EXPECT_EQ(*five,*(sum->augend));
EXPECT_EQ(*five,*(sum->addend));
delete five;
delete result;
}
示例8: main
//
// ------ Main (Driver) ------
int main(void)
{
Money Giveme(10,120);
Money IWant(11.20);
Money GotNone;
cout << " I gave you " ; Giveme.show(); cout << endl;
cout << " You Wanted " ; IWant.show(); cout << endl;
cout << " you got nothing " ; GotNone.show() ; cout << endl;
return 0;
}
示例9: updateInfo
void CompanyWidget::updateInfo()
{
int index = ui->company->currentIndex();
if (index < 0) {
return;
}
Company *company = (Company *) ui->company->itemData(index, PPLib::entityRole).toInt();
Money credit = company->fields["company_credit"];
ui->creditCustomer->setText(credit.toString());
Money debt = company->fields["company_debt"];
ui->debtCustomer->setText(debt.toString());
}
示例10: Sub
Money Money::Sub(Money b)
{
Money a;
RtoK();
b.RtoK();
a = *this;
a.rub = a.rub.Sub(b.rub);
KtoR();
b.KtoR();
return a;
}
示例11: BetModificationSetup
bool Wager::MethodPress(Money &cMoney, const Table &cTable, std::list<Bet> &lBets, const int nTimes)
{
BetModificationSetup(cTable, lBets);
if (m_bWon) ++m_nBetModCounter;
// If a bet won and counter is less than or equal to nTimes, Press the bet.
// 1) Loop through bets, find those that are modifiable and have won.
// 2) Double their wager
// 3) Set their state to Unresolved
int nNewWager = 0;
if (m_bWon)
{
if (m_nBetModCounter <= nTimes)
{
for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
{
if (it->Modifiable() && it->Won())
{
nNewWager = it->Wager() * 2;
cMoney.Decrement(nNewWager);
it->SetWager(nNewWager);
it->SetUnresolved();
}
}
}
else
{
m_nBetModCounter = 0;
}
}
return (false);
}
示例12: doubleWith2Decimal
Money Money::operator*(double r)
{
wasBelowZero=false;
wasZeroFirst=false;
long long int newtotal;
Money cash = doubleWith2Decimal(r);
newtotal= countPenny() * cash.countPenny();
QString total = QVariant(newtotal).toString();
QString rest = total.right(4);
if(rest.at(0)=='0')
wasZeroFirst=true;
return Money(newtotal / 10000, roundPennys(newtotal % 10000), wasZeroFirst);
}
示例13:
/*Money*/void Money::Div(Money b)
{
//Money a;
RtoK();
b.RtoK();
//a = *this;
//a.rub = a.rub.Div(b.rub);
rub.Div(b.rub);
KtoR();
b.KtoR();
//return a;
}
示例14: if
Decimal operator/(const Money& m1, const Money& m2) {
if (m1.currency() == m2.currency()) {
return m1.value()/m2.value();
} else if (Money::conversionType == Money::BaseCurrencyConversion) {
Money tmp1 = m1;
convertToBase(tmp1);
Money tmp2 = m2;
convertToBase(tmp2);
return tmp1/tmp2;
} else if (Money::conversionType == Money::AutomatedConversion) {
Money tmp = m2;
convertTo(tmp, m1.currency());
return m1/tmp;
} else {
QL_FAIL("currency mismatch and no conversion specified");
}
}
示例15: close_enough
bool close_enough(const Money& m1, const Money& m2, Size n) {
if (m1.currency() == m2.currency()) {
return close_enough(m1.value(),m2.value(),n);
} else if (Money::conversionType == Money::BaseCurrencyConversion) {
Money tmp1 = m1;
convertToBase(tmp1);
Money tmp2 = m2;
convertToBase(tmp2);
return close_enough(tmp1,tmp2,n);
} else if (Money::conversionType == Money::AutomatedConversion) {
Money tmp = m2;
convertTo(tmp, m1.currency());
return close_enough(m1,tmp,n);
} else {
QL_FAIL("currency mismatch and no conversion specified");
}
}