// mesbout.Cpp
// Fichier de definition des fonctions membres des boutons

#include "mesbout.h"
#include "distribu.h"
#include "monnayeur.h"
#include <iostream.h>
#include <string.h>

BoutonAnnul::BoutonAnnul( Monnayeur * m,
			  char      * Txt )
  {
  monn = m;
  buff = new char[strlen( Txt )+1];
  strcpy( buff, Txt );
  }

void BoutonAnnul::Clicke()
  {
  monn->annulation();
  }

BoutonProduit::BoutonProduit( Distributeur * d,
			      int num,
			      char         * Txt )
  {
  num_produit = num;
  dist        = d;
  buff = new char[strlen( Txt )+1];
  strcpy( buff, Txt );
  }

void BoutonProduit::Clicke()
  {
  dist->demande_produit( num_produit );
  }

BoutonPiece::BoutonPiece( Monnayeur * m,
			  float val,
			  char      * Txt )
  {
  valeur = val;
  monn   = m;
  buff = new char[strlen( Txt )+1];
  strcpy( buff, Txt );
  }

void BoutonPiece::Clicke()
  {
  monn->recevoir( valeur );
  if (monn->trop())        // si somme payee > prix et ne rend plus la monnaie
    monn->annulation();
  else if (monn->assez())  // si somme payee >= prix
    monn->AccesDist()->delivre_produit();
  }

