Advertisement
Guest User

cal

a guest
Feb 24th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. /*
  2.     Visual C++ - Travaux Pratique
  3.    
  4.     Exercice: 5
  5.     Etudiant: BOUELKHEIR Yassine
  6. */
  7.  
  8.  
  9. #include <iostream>
  10. #include <stdlib.h>
  11.  
  12. using namespace std;
  13.  
  14. class Calculatrice
  15. {
  16.     public:
  17.         int Value = 0;
  18.         int showMenu()
  19.         {
  20.             system("cls"); 
  21.                
  22.             int selection;
  23.             cout << "On a Value = " << Value <<", Choisissez une operation:\n\n\n1. Ajouter 1\n\n2. Multiplier par 2\n\n3. Soustraire 4\n\n4. Quitter\n\nOperation: ";
  24.             cin >> selection;
  25.             return this->setSelection(selection);
  26.         }
  27.         int setSelection(int selection)
  28.         {
  29.             switch(selection)
  30.             {
  31.                 case 1: {
  32.                     Value++;
  33.                     break;
  34.                 }
  35.                 case 2: {
  36.                     Value *= 2;
  37.                     break;
  38.                 }
  39.                 case 3:{
  40.                     Value -= 4;
  41.                     break;
  42.                 }
  43.                 case 4: {
  44.                     return -1;
  45.                     break;
  46.                 }
  47.                 default: {
  48.                     this->showMenu();
  49.                     break;
  50.                 }
  51.             }
  52.         }
  53. };
  54.  
  55. int main()
  56. {
  57.     Calculatrice Exemple;
  58.     while(1)
  59.     {
  60.         if(Exemple.showMenu() == -1) break;
  61.     }
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement