Skip to content

Commit

Permalink
correction article_affichage et ajout operator<<
Browse files Browse the repository at this point in the history
- correction de article_affichage::prix_vente_effectif
- ajout des fonctions :
  * article_affichage::ecrire_vers
  * operator<< pour article_affichage
  • Loading branch information
harenome committed Apr 26, 2014
1 parent 2619faa commit 4392d94
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions include/article_affichage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ class article_affichage
*/
article_affichage & operator= (article_affichage a);

/**
* \brief Écrire vers un flux de sortie.
* \param[in,out] os Flux de sortie.
* \return \c os.
*/
std::ostream & ecrire_vers (std::ostream & os) const;

private:
article _article; /**<- Article. */
article_stock _article_stock; /**<- Infos sur le stock de l'article. */
Expand All @@ -123,6 +130,14 @@ class article_affichage
// Fonctions non membres.
////////////////////////////////////////////////////////////////////////////////

/**
* \brief Opérateur \c <<.
* \param[in,out] os Flux de sortie.
* \param[in] a Article affichage.
* \return \c os.
*/
std::ostream & operator<< (std::ostream & os, const article_affichage & a);

/**
* \brief Échanger deux articles affichage.
* \param a Article affichage.
Expand Down
20 changes: 19 additions & 1 deletion src/article_affichage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ double article_affichage::prix_vente (void) const

double article_affichage::prix_vente_effectif (void) const
{
return rabais ().appliquer_a (prix_vente ());
double prix = prix_vente ();
prix -= rabais ().appliquer_a (prix);
return prix;
}

unsigned int article_affichage::quantite_stock (void) const
Expand Down Expand Up @@ -97,3 +99,19 @@ article_affichage & article_affichage::operator= (article_affichage a)
this->swap (a);
return * this;
}

std::ostream & article_affichage::ecrire_vers (std::ostream & os) const
{
os << _article << " ";
os << quantite_stock () << " " << rabais () << " " << prix_vente_effectif ();
return os;
}

////////////////////////////////////////////////////////////////////////////////
// Fonctions non membres.
////////////////////////////////////////////////////////////////////////////////

std::ostream & operator<< (std::ostream & os, const article_affichage & a)
{
return a.ecrire_vers (os);
}

0 comments on commit 4392d94

Please sign in to comment.