Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Visual C++ - Travaux Pratique
- Exercice: 5
- Etudiant: BOUELKHEIR Yassine
- */
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- class Calculatrice
- {
- public:
- int Value = 0;
- int showMenu()
- {
- system("cls");
- int selection;
- 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: ";
- cin >> selection;
- return this->setSelection(selection);
- }
- int setSelection(int selection)
- {
- switch(selection)
- {
- case 1: {
- Value++;
- break;
- }
- case 2: {
- Value *= 2;
- break;
- }
- case 3:{
- Value -= 4;
- break;
- }
- case 4: {
- return -1;
- break;
- }
- default: {
- this->showMenu();
- break;
- }
- }
- }
- };
- int main()
- {
- Calculatrice Exemple;
- while(1)
- {
- if(Exemple.showMenu() == -1) break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement