mat311111 a écrit 2 commentaires

  • [^] # Re: le code ne correspond pas l'exécution

    Posté par  . En réponse au message Simple question de logique ?. Évalué à 1. Dernière modification le 14 février 2020 à 09:15.

    Re Bonjour;

    Voici le code mais je viens de le re tester et je n'ai plus l'erreur.. 🤨

    #!/bin/bash
    
    
    #choix Joueur
    
    a=1
    
    
    
    while [ $a = 1 ]
    do
    read -p "Choisir parmis la pierre => P, la feuille => F et le cisaux => C " choixJ
    case "$choixJ" in
        P ) choixJ='P'
            a=0
        ;;
        F ) choixJ='F'
            a=0
        ;;
        C ) choixJ='C' 
            a=0
        ;;
        * ) echo "Mauvais Choix"
    esac
    
    done
    
    
    # Choix PC
    
    choixPC=$(( $RANDOM % 3 + 1 ))
    
    
    
    case "$choixPC" in
        1 ) choixPCL='P'
        ;;
        2 ) choixPCL='F'
        ;;
        3 ) choixPCL='C'
        ;;
        * ) echo "erreur "
    esac
    
    
    
    
    
    
    
    
    echo "Le pc a choissi => $choixPCL"
    
    
    
    
    # Resultat
    
    if [ $choixJ = 'P' ] && [ $choixPCL = 'P' ]; then
        echo "egalité"
    elif [ $choixJ = 'P' ] && [ $choixPCL = 'F' ]; then
        echo "Le PC a gagné"
    elif [ $choixJ = 'P' ] && [ $choixPCL = 'C' ]; then
        echo "Le joeur à gagné"
    #///////////////////////////////////////////////////////////////////////
    elif [ $choixJ = 'F' ] && [ $choixPCL = 'P' ]; then
        echo "Le joueur à gagné"
    elif [ $choixJ = 'F' ] && [ $choixPCL = 'F' ]; then
        echo "egalité"
    elif [ $choixJ = 'F' ] && [ $choixPCL = 'C' ]; then
        echo "Le PC a gagné"
    #///////////////////////////////////////////////////////////////////////
    elif [ $choixJ = 'C' ] && [ $choixPCL = 'P' ]; then
        echo "le pc à gagné"
    elif [ $choixJ = 'C' ] && [ $choixPCL = 'F' ]; then
        echo "le joueur à gagné"
    else
        echo "egalité"
    fi
  • [^] # Re: parce que...

    Posté par  . En réponse au message Simple question de logique ?. Évalué à 1.

    Merci pour l'explication et au passage merci pour la simplification !
    Je comprends mieux maintenant.