Notifications
BlackJack
Showcase
106
0
A simple game of BlackJack in Java
// TODO: Auto-generated Javadoc /** * The Class Blackjack. */ public class Blackjack { /** The money. */ protected float money; /** * Returns a String that is the convertion of money to string. * @return Float money to string */ @Override public String toString() { return Float.toString(money); } /** * Class constructor that stores the initial balance of player. * <p> * This method is only called at the begging. * * @param d the d */ public Blackjack(float d) { money = d; } /** * Adds q to the player balance. * <p> * * @param q the q */ void credit(float q) { money+=q; } /** * Subtracts q to the player balance. * <p> * * @param q the q */ void debit(float q) { money-=q; } /** * Returns boolean that checks if the player as the money to bet. * <p> * This method also checks if the player run out of money. * * @param min_bet the min_bet * @param money_to_bet the money_to_bet * @param game the game * @return boolean true if it has the money, else false. * @see GameRunner */ boolean check(float min_bet,float money_to_bet, GameRunner game){ if(money<min_bet){ System.out.println("Out of money to play!"); System.exit(0); }else if(money_to_bet > money){ System.out.println("You Dont Have enought money to make that bet!"); game.decreaseBet(); return false; } return true; } /** * Exits if the command given is "q" * <p> * before exiting the game gives the msgs "bye!". */ public static void quitGame(){ System.out.println("bye!"); System.exit(0); }
Tags:Java
João Neto Cordeiro
Software Engineer - Programmer
1
Comments