Пример #1
0
Constante* Pile::dupliquer()
{
    Constante* temp = p.top();
    string s = temp->getChaine();

    if(temp == NULL) return NULL;

    if(temp->getType() == entier)
    {
        Entier* Dup = new Entier(s);
        return Dup;
    }
    else if(temp->getType() == rationnel)
    {
        Rationnel* Dup = new Rationnel(s);
        return Dup;
    }
    else if(temp->getType() == reel)
    {
        Reel* Dup = new Reel(s);
        return Dup;
    }
    else
    {
        Complexe* temp2 = dynamic_cast<Complexe*>(temp);
        Complexe* Dup = new Complexe(s, temp2->getContient());
        return Dup;
    }
}
Пример #2
0
bool Inferieur::application(const Constante& c1, const Constante& c2){

    bool result;
    if(c1.getType() > c2.getType()){
            result = c1<c2;
    }
    else{
            result = c2<c1;
    }
    return result;
}
Пример #3
0
bool Egal::application(const Constante& c1, const Constante& c2){

    bool result;
    if(c1.getType() > c2.getType()){
            result = c1==c2;
    }
    else{
            result = c2==c1;
    }
    return result;
}
Пример #4
0
/*!
  * bool operator<(const Constante& c) const
  * \brief operator<
  * Methode vérifiant si l'entier manipulé est inférieur à la constante passé en argument
  * Si la constante est un entier, alors on effectue l'operation adequate
  * \param c
  * \return true si l'entier manipulé est inférieur, false sinon
  */
bool Entier::operator<(const Constante & c) const
{
    switch(c.getType()){
        case Constante::ENTIER:
        {
            if(this->_entier < static_cast<const Entier&>(c)._entier)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}