Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Proj4 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- String[] suitKey = {"Spades" , "Clubs", "Hearts", "Diamonds"};
- int[] deck = {2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14,2,3,4,5,6,7,8,9,10,11,12,13,14};
- int cNum =0;
- int[] value = new int[5];
- int[] suit = new int[5];
- int nos=0;
- int pair=0;
- int score=0;
- boolean pairFound=false;
- int pairValue=30;
- Random rand = new Random();
- while(cNum < 5){
- int n = rand.nextInt(52);
- if (deck[n] != 20){
- value[cNum] = deck[n];
- if (n <13){
- suit[cNum] = 1;
- }
- else if (n <26){
- suit[cNum]=2;
- }
- else if (n <39){
- suit[cNum]=3;
- }
- else if (n <52){
- suit[cNum]=4;
- }
- deck[n] =20;
- cNum++;
- }
- }
- for (int a=0;a<5;a++){
- for (int b=a; b<5;b++){
- if(a!=b){
- if (value[a] == value[b])
- score=2;
- }
- }
- }
- for(int g = 0; g < value.length - 1; g++){
- if(value[g] == pairValue) {
- continue;
- }
- for(int c = g + 1; c < value.length; c++){
- if(value[g] == value[c]) {
- if(value[g] != pairValue) {
- if(pairFound) {
- score =3;
- }
- pairValue = value[g];
- pairFound = true;
- break;
- }
- }
- }
- }
- for (int y=0;y<5;y++)
- System.out.println(value[y] + " of " + suit[y]);
- System.out.println("Shuffling the cards");
- System.out.println("Dealing the cards\n");
- System.out.println("Here are your five cards...");
- for (int j=0;j<5;j++){
- int sNum = suit[j];
- if (value[j] < 11)
- System.out.println(value[j]+ " of "+ suitKey[sNum-1]);
- else if(value[j] == 11)
- System.out.println("Jack of " + suitKey[sNum-1]);
- else if(value[j] == 12)
- System.out.println("Queen of " + suitKey[sNum-1]);
- else if(value[j] == 13)
- System.out.println("King of " + suitKey[sNum-1]);
- else if(value[j] == 14)
- System.out.println("Ace of " + suitKey[sNum-1]);
- }
- System.out.println("MY score is " + score);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement