dimanche 5 mai 2019

How do I run loop inside if statement?

How do I run loops inside the if-else statement until equality achieved?

I've tried this, but didn't work:

    if (!Card1.equals(Card2)){
        System.out.println("Lose");
        While (!Card1.equals(Card2)){
        String Card1 = arrayValue[valueRandom] + arraySuit[suitRandom];
        String Card2 = arrayValue[valueRandom2] + arraySuit[suitRandom2];
        System.out.println("Card 1: " + Card1);
        System.out.println("Card 2: " + Card2);
        }
    }
    else{
        System.out.println("Win");
    }

I expect the random of array will start again if Card1 does not equal to Card2.

Thanks!




Aucun commentaire:

Enregistrer un commentaire