Memilih Kartu

Assalamualaikum semuanya, ..
Hari ini saya akan membagikan cara memilih kartu pada pemrograman java, . .
Silahkan di coba, . .

public class PickCards {

public static void main(String[] iriahus) {
int rank = 1 + (int)(Math.random() * 13);
int suit = 1 + (int)(Math.random() * 4);

switch (rank) {
case 1:
System.out.print("Ace");
break;
case 2:
System.out.print("Two");
break;
case 3:
System.out.print("Three");
break;
case 4:
System.out.print("Four");
break;
case 5:
System.out.print("Five");
break;
case 6:
System.out.print("Six");
break;
case 7:
System.out.print("Seven");
break;
case 8:
System.out.print("Eight");
break;
case 9:
System.out.print("Nine");
break;
case 10:
System.out.print("Ten");
break;
case 11:
System.out.print("Jack");
break;
case 12:
System.out.print("Queen");
break;
case 13:
System.out.print("King");
break;
default:
break;
}

switch (suit) {
case 1:
System.out.println(" of the Clubs");
break;
case 2:
System.out.println(" of the Diamonds");
break;
case 3:
System.out.println(" of the Hearts");
break;
case 4:
System.out.println(" of the Spades");
break;
default:
break;
}
}

}

Semoga bermanfaat, . .


Subscribe to receive free email updates:

0 Response to "Memilih Kartu"

Post a Comment