void setTotalPrice() { Product* sweeper = firstProduct; double suM=0; if(sweeper != NULL) { while(sweeper->getNextProduct() != NULL) { suM += sweeper->getPrice(); sweeper = sweeper->getNextProduct(); } suM += sweeper->getPrice(); } sum = suM; }
// Calcular valor total dos produtos do carrinho float getTotalPrice() { Product* sweeper = firstProduct; float sum=0; while(sweeper->getNextProduct() != NULL) sum += sweeper->getPrice(); return sum; }
// Metodo que exibe na tela o resumo das compras feitas e o valor total e o desconto void purchaseResume() { Product * sweeper = firstProduct; sum = 0; while (sweeper != NULL) { cout<<sweeper->getID()<<" "<<sweeper->getName()<<" "<<setprecision(2)<<fixed<<sweeper->getPrice()<<endl; cout<<endl; sum += sweeper->getPrice(); sweeper = sweeper->getNextProduct(); } cout<<endl; cout<<endl; if(fixedDiscount) { cout<<"Descontos: -"<<setprecision(2)<<fixed<<discount<<endl; cout<<endl; sum -= discount; cout<<"Total: "<<setprecision(2)<<fixed<<sum<<endl; } else { discount = (discount/100)*sum; cout<<"Descontosp: -"<<setprecision(2)<<fixed<<discount<<endl; cout<<endl; sum -= discount; cout<<"Total: "<<setprecision(2)<<fixed<<sum<<endl; } }