LitteraleCalculable& Entier::mult(const LitteraleCalculable& l) const{ const Entier* ptEntier = dynamic_cast<const Entier*>(&l); if (ptEntier != 0){ // Entier * Entier Entier* res = new Entier(value * ptEntier->getValue()); LitteraleCalculable& ref = *res; return ref; } else{ const Rationnel* ptRationnel = dynamic_cast<const Rationnel*>(&l); if (ptRationnel!= 0){ // Entier * Rationnel Entier num = (value * ptRationnel->getNum().getValue()); Entier den = (ptRationnel->getDen().getValue()); int type = simplifier(num, den); if (type == 0){ Rationnel* res = new Rationnel(num,den); LitteraleCalculable& ref = *res; return ref; } if (type == 1) { Entier v = num.div(den); Entier* res = new Entier(v.getValue()); LitteraleCalculable& ref = *res;//spl->simplifier(res); return ref; } } else { const Reel* ptReel = dynamic_cast<const Reel*>(&l); if (ptReel!=0){ // Entier * Reel Reel* res= new Reel(value * ptReel->getValue()); LitteraleCalculable& ref = *res; return ref; }else{ const Expression* ptExpression=dynamic_cast<const Expression*>(&l); if (ptExpression!=0){ // Entier * Expression LitteraleCalculable& ref = ptExpression->mult(*this); return ref; }else{ const Complexe* ptComplexe = dynamic_cast<const Complexe*>(&l); if (ptComplexe!=0){ // Entier * Complexe LitteraleCalculable& ref = ptComplexe->mult(*this); return ref; } } } } } throw CalcException("le type de l'argument 2 n'est pas reconnu"); Entier* res = new Entier(); LitteraleCalculable& ref = *res; return ref; }
Entier::Entier(const Entier &e) { this->value = e.getValue(); }