示例#1
0
void FirmView::RedrawMesons(QPainter *p)
{
    p->fillRect(108, 80, 39, 20, PlColor[4]);
    p->fillRect(59, 80, 39, 20, PlColor[4]);
    p->fillRect(2, 102, 153, 42, PlColor[4]);

    CMoney inc = fp->GetCurIncome();
    QString tmpStr = inc.toString();
    p->drawText(QRect(108, 80, 39, 20), Qt::AlignCenter, tmpStr);

    quint8 multi = fp->GetMultiplicator();
    tmpStr.setNum(multi);
    p->drawText(QRect(59, 80, 39, 20), Qt::AlignCenter, "x" + tmpStr);

    QRect Pos[6][6] = {
            QRect(57, 114, 49, 20), QRect(), QRect(), QRect(), QRect(), QRect(),
            QRect(32, 114, 49, 20), QRect(82, 114, 49, 20), QRect(), QRect(), QRect(), QRect(),
            QRect(8, 114, 49, 20), QRect(57, 114, 49, 20), QRect(106, 114, 49, 20), QRect(), QRect(), QRect(),
            QRect(32, 105, 49, 20), QRect(82, 105, 49, 20), QRect(22, 124, 59, 20), QRect(82, 124, 59, 20), QRect(), QRect(),
            QRect(8, 105, 49, 20), QRect(57, 105, 49, 20), QRect(106, 105, 49, 20), QRect(32, 124, 49, 20), QRect(82, 124, 49, 20), QRect(),
            QRect(8, 105, 49, 20), QRect(57, 105, 49, 20), QRect(106, 105, 49, 20), QRect(4, 124, 49, 20), QRect(57, 124, 49, 20), QRect(106, 124, 49, 20)
    };
    for (quint32 i=0; i<fp->m_nu; i++) {
        if (fp->mz[i].invest != 0)
            tmpStr = fp->mz[i].invest.toString();
        else
            tmpStr = "";
        switch (fp->mz[i].type) {
        case 0:
            tmpStr += "-";
            break;
        case 1:
            tmpStr += "*-";
            break;
        case 2:
            tmpStr += "**-";
            break;
        case 3:
            tmpStr += "- +";
        }
        QString tmpStr1;
        tmpStr1 = fp->mz[i].income.toString();
        tmpStr += tmpStr1;
        if (i == fp->cur_mz - 1) {
            p->setPen(QColor(255, 0, 0));
        } else {
            p->setPen(QColor(0, 0, 0));
        }
        p->drawText(Pos[fp->m_nu-1][i], Qt::AlignCenter, tmpStr);
    }
}
示例#2
0
//基本数据类型不能重载
// int operator+ (int nMoney, int obj)
// {
//   return obj + nMoney + 1;
//  }
int main(int argc, char* argv[])
{
	CMoney money;
  money.AddMoney(10); //存钱

  money += 10; //money.operator+=(10);
  int n;
  1 + n + n;

  money = 1 + money + money  + 1 + 2;
  1 + money;
  &money;
	return 0;
}
示例#3
0
/*
*   Calculate time required to move between certain prices
*   with certain initial direction of price change.
*
*   PARAMETERS:
*           IN  fStartPrice     - price at the start of the time interval
*           IN  fEndPrice       - price at the end of the time interval
*           IN  iStartDirection - direction (up or down) on the price curve at the start of the time interval
*
*   RETURNS:
*           seconds required to move from the start price to the end price
*/
double  CMEESecurity::CalculateTime(
                                        CMoney fStartPrice,
                                        CMoney fEndPrice,
                                        int iStartDirection)
{
    int     iHalfPeriod = m_iPeriod / 2;

    // Distance on the price curve from StartPrice to EndPrice (in dollars)
    //
    CMoney fDistance;

    // Amount of time (in seconds) needed to move $1 on the price curve.
    // In half a period the price moves over the entire price range.
    //
    double fSpeed = iHalfPeriod / m_fRange.DollarAmount();

    if (fEndPrice > fStartPrice)
    {
        if (iStartDirection > 0)
        {
            fDistance = fEndPrice - fStartPrice;
        }
        else
        {
            fDistance = (fStartPrice - m_fRangeLow) + (fEndPrice - m_fRangeLow);
        }
    }
    else
    {
        if (iStartDirection > 0)
        {
            fDistance = (m_fRangeHigh - fStartPrice) + (m_fRangeHigh - fEndPrice);
        }
        else
        {
            fDistance = fStartPrice - fEndPrice;
        }
    }

    return fDistance.DollarAmount() * fSpeed;
}
示例#4
0
// Define / operator to make possible double operand on the left
//
double operator /(double l_f, CMoney r_m)
{
    return l_f / r_m.DollarAmount();
}