Guest User

Untitled

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <cctype>
  5.  
  6. using namespace std;
  7.  
  8. class location
  9. {
  10. private:
  11. int nbPieces;
  12. public:
  13. location();
  14. void init(int);
  15. int getNbPieces();
  16. void setNbPieces(int);
  17. void afficher();
  18. };
  19.  
  20. location::location()
  21. {
  22. }
  23.  
  24. void location::init(int new_nbPieces)
  25. {
  26. nbPieces=new_nbPieces;
  27. }
  28.  
  29. int location::getNbPieces()
  30. {
  31. return nbPieces;
  32. }
  33.  
  34. void location::setNbPieces(int new_nbPieces)
  35. {
  36. nbPieces=new_nbPieces;
  37. }
  38.  
  39. void location::afficher()
  40. {
  41. cout<<"Nombre de pieces de la residence : "<<nbPieces<<endl;
  42. }
  43.  
  44.  
  45. int main()
  46. {
  47. bool choixPieces=false;
  48.  
  49. location maison;
  50.  
  51. while(choixPieces==false)
  52. {
  53. char nbPieces;
  54. cout<<"Combien de pieces possede la residence ? : ";
  55. cin>>nbPieces;
  56.  
  57. if(isdigit(nbPieces))
  58. {
  59. choixPieces=true;
  60. maison.init(nbPieces);
  61. }
  62. else
  63. {
  64. cout<<endl<<"La saisie est incorrecte, veuillez recommencer !"<<endl;
  65. system("PAUSE");
  66. system("CLS");
  67. }
  68. }
  69.  
  70. maison.afficher();
  71. return 0;
  72. }
Add Comment
Please, Sign In to add comment