Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Les classes
- * TP 1
- * @author Hugo FIQUET
- * @version du 28/11/14
- */
- import iut.algo.*;
- public class PotARendre
- {
- public static void main(String [] arg)
- {
- int qteA, qteB, qteRch;
- int nbTour, min;
- Pot potA = new Pot("A",qteA);
- Pot potB = new Pot("B",qteB);
- Pot potC = new Pot("C",qteA+qteB+qteRch);
- char act1, act2;
- nbTour = 0;
- qteA = Clavier.lire_int();
- qteB = Clavier.lire_int();
- qteRch = Clavier.lire_int();
- while (potC.getContenu() < qteRch && nbTour < 100)
- {
- act1 = Clavier.lire_char();
- act2 = Clavier.lire_char();
- if (act1='A') { potO = potA; }
- else { potO = potA; }
- switch (act2)
- {
- case 'A' : potD = potA;
- break;
- case 'B' : potD = potB;
- break;
- case 'C' : potD = potC;
- break;
- }
- switch (act2)
- {
- case '0' : potO.jeter();
- break;
- case '1' : potO.ajouter(getLibre());
- break;
- default : Min(potO.getContenu(), potD.getLibre());
- potO.enlever(Min);
- potB.ajouter(Min);
- break;
- }
- System.out.println (potA.getContenu(), potB.getContenu(), potC.getContenu());
- nbTour++;
- }
- if(potC.getContenu() = qteRch)
- System.out.println("Gagné en " + nbTour);
- else
- System.out.println ("Perdu");
- }
- public static Min (int entier1, int entier2)
- {
- if(entier1<entier2)
- {
- return (entier1);
- }
- else
- {
- return (entier2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement