Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.truttle.javagony.blackjack;
- import java.util.Scanner;
- public class Main {
- /**
- TRUTTLE1 PRESENTS:
- Blackjack without any if, while, for, or switch commands!
- AKA Blackjack in Javagony!
- https://esolangs.org/wiki/Javagony
- */
- private static int[] playerCards = new int[5];
- private static int[] dealerCards = new int[5];
- private static int currentCard;
- public static void main(String[] args)
- {
- playerCards[0] = (int)(Math.random()*11)+1;
- playerCards[1] = (int)(Math.random()*10)+1;
- dealerCards[0] = (int)(Math.random()*11)+1;
- dealerCards[1] = (int)(Math.random()*10)+1;
- System.out.println("PLAYER'S CARDS: ");
- displayPlayerCards(0);
- System.out.println("");
- System.out.println("PLAYER CARD SUM :: " + sumPlayerCards());
- System.out.println("");
- System.out.println("DEALER'S CARDS: ");
- displayDealerCards(1);
- currentCard = 2;
- System.out.println("");
- System.out.println("");
- playersTurn();
- }
- private static void displayPlayerCards(int card)
- {
- try
- {
- int z = 1/playerCards[card];
- System.out.print(playerCards[card] + " :: ");
- card++;
- displayPlayerCards(card);
- }
- catch(Exception e)
- {
- return;
- }
- }
- private static void displayDealerCards(int card)
- {
- try
- {
- int z = 1/dealerCards[card];
- System.out.print(dealerCards[card] + " :: ");
- card++;
- displayDealerCards(card);
- }
- catch(Exception e)
- {
- return;
- }
- }
- private static void playersTurn()
- {
- System.out.println("[H] - Hit :: [Anything Else] - Stay");
- System.out.println("!!![H] must be a capital H!!!");
- Scanner sc = new Scanner(System.in);
- String x = sc.next();
- int h = (int)x.charAt(0);
- h -= 72;
- try
- {
- int z = 1/h;
- currentCard = 2;
- dealersTurn();
- return;
- }
- catch(Exception e)
- {
- playerCards[currentCard] = (int)(Math.random()*11)+1;
- currentCard++;
- System.out.println("PLAYER'S CARDS: ");
- displayPlayerCards(0);
- System.out.println("");
- try
- {
- int bust = 1/checkForBust();
- try
- {
- int win = 1/(21-sumPlayerCards());
- try
- {
- int v = 1/(currentCard-5);
- playersTurn();
- }
- catch(Exception f)
- {
- System.out.println("You win! You drew 5 cards and didn't bust! :)");
- return;
- }
- }
- catch(Exception f)
- {
- System.out.println("You win! You have 21 points! :)");
- return;
- }
- }
- catch(Exception f)
- {
- System.out.println("You busted! You lose! :(");
- return;
- }
- }
- }
- private static int checkForBust()
- {
- System.out.println("PLAYER CARD SUM :: " + sumPlayerCards());
- try
- {
- int x = Math.addExact(sumPlayerCards(),Integer.MAX_VALUE-21);
- return 1;
- }
- catch(Exception e) {return 0;}
- }
- private static int sumPlayerCards()
- {
- return playerCards[0] + playerCards[1] + playerCards[2] + playerCards[3] + playerCards[4];
- }
- private static void dealersTurn()
- {
- int dealerAction = sumDealerCards()-17;
- dealerAction*=-1;
- try
- {
- int x = Math.addExact(dealerAction,Integer.MAX_VALUE);
- System.out.println("DEALER :: Stay!");
- showFinalResults();
- }
- catch(Exception e)
- {
- System.out.println("DEALER :: Hit!");
- dealerCards[currentCard] = (int)(Math.random()*11)+1;
- currentCard++;
- System.out.println("");
- try
- {
- int bust = 1/checkForBustDealer();
- try
- {
- int win = 1/(21-sumDealerCards());
- try
- {
- int v = 1/(currentCard-5);
- dealersTurn();
- }
- catch(Exception f)
- {
- System.out.println("You lose! The dealer drew 5 cards and didn't bust! :(");
- System.out.println("");
- System.out.println("The dealer got: " + sumDealerCards());
- System.out.println("DEALER'S CARDS: ");
- displayDealerCards(0);
- System.out.println("");
- return;
- }
- }
- catch(Exception f)
- {
- System.out.println("You lose! The dealer got 21 points! :(");
- System.out.println("");
- System.out.println("The dealer got: " + sumDealerCards());
- System.out.println("DEALER'S CARDS: ");
- displayDealerCards(0);
- return;
- }
- }
- catch(Exception f)
- {
- System.out.println("The dealer busted! You win! :)");
- System.out.println("");
- System.out.println("The dealer got: " + sumDealerCards());
- System.out.println("DEALER'S CARDS: ");
- displayDealerCards(0);
- System.out.println("");
- return;
- }
- }
- }
- private static int checkForBustDealer()
- {
- try
- {
- int x = Math.addExact(sumDealerCards(),Integer.MAX_VALUE-21);
- return 1;
- }
- catch(Exception e) {return 0;}
- }
- private static int sumDealerCards()
- {
- return dealerCards[0] + dealerCards[1] + dealerCards[2] + dealerCards[3] + dealerCards[4];
- }
- private static void showFinalResults()
- {
- System.out.println("");
- System.out.println("FINAL RESULTS:");
- System.out.println("The player got: " + sumPlayerCards());
- System.out.println("PLAYER'S CARDS: ");
- displayPlayerCards(0);
- System.out.println("");
- System.out.println("");
- System.out.println("The dealer got: " + sumDealerCards());
- System.out.println("DEALER'S CARDS: ");
- displayDealerCards(0);
- System.out.println("");
- int w = sumPlayerCards()-sumDealerCards();
- try
- {
- int t = 1/w;
- try
- {
- int v = Math.addExact(w, Integer.MAX_VALUE);
- System.out.println("You lose! :(");
- }
- catch(Exception e)
- {
- System.out.println("You win! :)");
- }
- }
- catch(Exception e)
- {
- System.out.println("It was a tie!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement