73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "ex3/Addition.cpp"
|
|
#include "ex3/Soustraction.cpp"
|
|
#include "ex3/Multiplication.cpp"
|
|
#include "ex3/Division.cpp"
|
|
#include "ex3/DivisionEuclidienne.cpp"
|
|
#include "ex3/Trinome.cpp"
|
|
|
|
using namespace std;
|
|
|
|
|
|
int main(){
|
|
int choix(0);
|
|
|
|
char input[8] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
|
|
char output[8] = {'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'};
|
|
|
|
/* [1] On initialise les operations
|
|
=========================================================*/
|
|
vector<Operator*> operations;
|
|
|
|
// On ajoute les operations;
|
|
operations.push_back( new Addition() );
|
|
operations.push_back( new Soustraction() );
|
|
operations.push_back( new Multiplication() );
|
|
operations.push_back( new Division() );
|
|
operations.push_back( new DivisionEuclidienne() );
|
|
operations.push_back( new Trinome() );
|
|
|
|
|
|
/* [2] Choix de l'operation a executer
|
|
=========================================================*/
|
|
do{
|
|
cout << " +-------------------------+" << endl;
|
|
for( int i = 0 ; i < operations.size() ; i++ )
|
|
cout << " + " << i << ") " << operations[i]->getLibelle() << endl;
|
|
cout << " +-------------------------+" << endl;
|
|
cout << " + Choix: ";
|
|
cin >> choix;
|
|
cout << endl << endl;
|
|
cout << "=======================================" << endl;
|
|
}while( choix < 0 || choix >= operations.size() );
|
|
|
|
|
|
/* [3] On recupere les operandes pour le calcul
|
|
=========================================================*/
|
|
float scanner;
|
|
int countOp(0);
|
|
while( operations[choix]->missingOperand() ){
|
|
|
|
cout << input[countOp] << " = ";
|
|
cin >> scanner;
|
|
cout << endl;
|
|
|
|
operations[choix]->addOperand(scanner);
|
|
countOp++;
|
|
}
|
|
|
|
float* result = operations[choix]->calc();
|
|
|
|
for( int i = 0 ; result[i] != '\0' ; i++ )
|
|
cout << output[i] << " = " << result[i] << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|