mercredi 28 octobre 2015

Need something better than a massive if else if a specific random number is returned

Hopefully you can see what I am going for here. Obviously this code doesn't work but I'm basically trying to say if the random number is one of these values, run this code. If the random number is another value run that code. I need something that is equivalent to a big or statement without using a large if-else. Thanks

    static int cardNumber = rnd.nextInt(13) + 1;

    if (cardNumber == 1||11||12||13)
    {
        System.out.println(faceCard + " of " + suit);
    } 
    else 
    {
        System.out.println(cardNumber + " of " + suit);
    }

Aucun commentaire:

Enregistrer un commentaire