T& Pile<T>::MEAN(const unsigned int x) const{ T& tmp = this->SUM(x); Operation::Div * div = new Operation::Div(); Pile<T> pileTmp; pileTmp.addPile(tmp); pileTmp.addPile(new Nombre::Entier(x)); T* res = div->calcul(pileTmp); delete div; delete pileTmp; T& ref = *res; return ref; }
Pile<T>& Pile<T>::pileResultat() const{ Pile<T> p = this->clone(); Pile<T> res; for(int i=0;i<p.size();i++) { if(p.at(i).isOperateur()) { if(p.at(i).isBinaire()) { p.DROP(); p.DROP(); p.DROP(); } else { // unaire p.DROP(); p.DROP(); } } else { res.addPile(p.pop()); } } delete p; Pile<T>& ref = res; return ref; }
void Collection_Onglet::chargerContexte() { QString file = "save.dat"; QFile fread(file); fread.open(QFile::ReadOnly | QFile::Text); QDomDocument doc; doc.setContent(&fread, false); QDomElement racine = doc.documentElement(); racine = racine.firstChildElement(); while(!racine.isNull()) { if(racine.tagName()== "onglet"){ //creation onglet Onglet* o = new Onglet(); QDomElement element = racine.firstChildElement(); while(!element.isNull()) { DataGestion * dg = new DataGestion(); if(element.tagName()=="paffichage") { Pile<QString> ps; QDomElement data = element.firstChildElement(); while(!data.isNull()) { Pile<QString> tmp1; if(element.tagName()=="data") { QString valeur = data.text(); tmp1.addPile(&valeur); } for(int i=0;i<tmp1.size();i++){ ps.addPile(tmp1.pop()); } } dg->setAffichage(ps); } else if(element.tagName()=="pstockage") { Pile<Nombre::Data> pst; QDomElement data = element.firstChildElement(); while(!data.isNull()) { Pile<QString> tmp1; if(element.tagName()=="data") { QString valeur = data.text(); tmp1.addPile(&valeur); } for(int i=0;i<tmp1.size();i++){ pst.addPile(dg->getFactory().creer(*tmp1.pop())); } } dg->setStockage(pst); } else if(element.tagName()=="pretablir") { Pile<Nombre::Data> pr; QDomElement data = element.firstChildElement(); while(!data.isNull()) { Pile<QString> tmp1; if(element.tagName()=="data") { QString valeur = data.text(); tmp1.addPile(&valeur); } for(int i=0;i<tmp1.size();i++){ pr.addPile(dg->getFactory().creer(*tmp1.pop())); } } dg->setStockage(pr); } else if(element.tagName()=="degre") { QString d = element.text(); if(d=="O") o->setDegre(true); else o->setDegre(false); } else if(element.tagName()=="complexe") { QString c = element.text(); if(c=="O") o->setComplexe(true); else o->setComplexe(false); } else if(element.tagName()=="type") { QString t = element.text(); if(t=="integer") o->setType(Integer); else if(t=="real") o->setType(Real); else if(t=="ratio") o->setType(Ratio); } o->setDataGestion(*dg); element = element.nextSiblingElement(); } this->ajouterOnglet(o); } racine = racine.nextSiblingElement(); } fread.close(); }