Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.*;
- public class Proj4 {
- /*
- You must include the following statements below in the code
- that you submit to get full credit. Use hardcoded values
- to test each of the possible hands.
- Project must work if any of the hardcoded arrays are uncomment
- with your random card generator portion comment out)
- GTAs will use these values to test your program
- Assume suits are numbered 1-4
- Assume 11=Jack, 12=Queen 13=King 14=Ace
- */
- // Used for testing different hands ... comment out dealing cards
- // and initialize when declared
- // Royal Flush
- //int[] value = {10, 12, 14, 13, 11};
- //int[] suit = {1,1,1,1,1};
- // Straight Flush
- //int[] value = {9, 7, 8, 6, 5};
- //int[] suit = {1,1,1,1,1};
- // 4 of kind
- //int[] value = {9, 7, 9, 9, 9};
- //int[] suit = {1,2,3,4,1};
- // Full House
- //int[] value = {9, 7, 9, 7, 9};
- //int[] suit = {1,2,3,4,1};
- // Flush
- //int[] value = {9, 10, 8, 6, 5};
- //int[] suit = {1,1,1,1,1};
- // Straight
- //int[] value = {9, 7, 8, 6, 5};
- //int[] suit = {1,2,4,3,1};
- // 3 of kind
- //int[] value = {9, 7, 9, 2, 9};
- //int[] suit = {1,2,3,4,1};
- // Two Pair
- //int[] value = {9, 7, 9, 2, 7};
- //int[] suit = {1,2,3,4,1};
- // One Pair
- //int[] value = {9, 7, 8, 2, 7};
- //int[] suit = {1,2,3,4,1};
- // High Card (Ace)
- //int[] value = {9, 7, 8, 14, 11};
- //int[] suit = {1,2,3,4,1};
- // } // end main
- // } // end class
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner sc = new Scanner(System.in);
- System.out.println("**Welcome to the 2017 Las Vegas Poker Festival!**");
- System.out.println("Application developed by Yoav Bittan");
- 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 val = 0;
- String strength = "none";
- int[] value = new int[0];
- int[] p = new int[0];
- int[] s = new int[0];
- int[] suit = new int[0];
- Random rand = new Random();
- while(val < 5){
- int n = rand.nextInt(52);
- if (deck[n] != 20){
- value[val] = deck[n];
- if (n <13){
- suit[val] = 1;
- }
- else if (n <26){
- suit[val]=2;
- }
- else if (n <39){
- suit[val]=3;
- }
- else if (n <52){
- suit[val]=4;
- }
- deck[n] = 20;
- val++;
- }
- }
- //for (int p=0;p<5;p++){
- //if (value[p])
- //}
- // 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]);
- // high card
- if (value[1] > value[2]){
- if (value[1] > value[3]){
- if(value[1] > value[4]){
- if(value[1] > value[0]){
- strength = ("High card" + value[1]);
- }
- }
- }
- }
- if (value[2] > value[1]){
- if (value[2] > value[3]){
- if(value[2] > value[4]){
- if(value[2] > value[0]){
- strength = ("High card" + value[2]);
- }
- }
- }
- }
- if (value[3] > value[1]){
- if (value[3] > value[2]){
- if(value[3] > value[4]){
- if(value[3] > value[0]){
- strength = ("High card" + value[3]);
- }
- }
- }
- }
- if (value[4] > value[1]){
- if (value[4] > value[2]){
- if(value[4] > value[3]){
- if(value[4] > value[0]){
- strength = ("High card" + value[1]);
- }
- }
- }
- }
- if (value[0] > value[1]){
- if (value[0] > value[2]){
- if(value[0] > value[3]){
- if(value[0] > value[4]){
- strength = ("High card" + value[1]);
- }
- }
- }
- }
- // all the pairs
- if (value[1] == p[2]){
- strength = "pair";}
- if (value[1] == p[3]){
- strength = "pair";}
- if (value[1] == p[4]){
- strength = "pair";}
- if (value[1] == p[0]){
- strength = "pair";}
- /////////////////
- if (value[2] == p[1]){
- strength = "pair";}
- if (value[2] == p[3]){
- strength = "pair";}
- if (value[2] == p[4]){
- strength = "pair";}
- if (value[2] == p[0]){
- strength = "pair";}
- /////////////////
- if (value[3] == p[1]){
- strength = "pair";}
- if (value[3] == p[2]){
- strength = "pair";}
- if (value[3] == p[4]){
- strength = "pair";}
- if (value[3] == p[0]){
- strength = "pair";}
- ////////////////////
- if (value[4] == p[1]){
- strength = "pair";}
- if (value[4] == p[2]){
- strength = "pair";}
- if (value[4] == p[3]){
- strength = "pair";}
- if (value[4] == p[0]){
- strength = "pair";}
- //////////////////
- if (value[0] == p[1]){
- strength = "pair";}
- if (value[0] == p[2]){
- strength = "pair";}
- if (value[0] == p[3]){
- strength = "pair";}
- if (value[0] == p[4]){
- strength = "pair";}
- ///
- // 2 pair
- System.out.println(strength);
- }
- }
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement