[JAVA] [Production progress] BlackJack: 03

This progress

This is a continuation from Last time.

--The dealer's behavior after the player's behavior is completed --Compare the scores of the player and the dealer and settle

It has become lighter than the last time. Then to the detailed contents.

Contents

Dealer behavior

Basically, it is designed to do only Hit. For the unusual part, I refer to the dealer's score and loop with a While statement until it reaches 15 points or more or exceeds the player's score.

BlackJack_main.java


		System.out.println("The dealer's second card is["+handCard_dealer.get(1)+"]was");
		System.out.println("The dealer's hand"+handCard_dealer+"is");
		System.out.println("The dealer's score is"+cardPoints_dealer+"Is a point");

		//Dealer behavior
		while(cardPoints_dealer<15 || cardPoints_dealer<=cardPoints) {
			handCard_dealer.add(bills.get(0));
			System.out.println("The card drawn by the dealer["+handCard_dealer.get(handCard_dealer.size()-1)+"]is");
			cardPoints_dealer+=points.get(handCard_dealer.get(handCard_dealer.size()-1));
			bills.remove(0);
			System.out.println("The dealer's score is"+cardPoints_dealer+"Is a point");
			JUDGE.judge(cardPoints,cardPoints_dealer);
			if(JUDGE.result != "") {
				System.out.println("BlackJack is over! Please play again ☆");
				return;
			}
		}

Settlement

Conditional branching is done with a simple if statement.

blackJack_main.java


		//Score comparison / win / loss
		System.out.println("The dealer's hand"+handCard_dealer+"is");
		System.out.println("Your score is"+cardPoints+"Is a point");
		if(cardPoints==cardPoints_dealer) {
			System.out.println("////It's a draw.////");
			System.out.println("BlackJack is over! Please play again ☆");
			return;
		}else if(cardPoints>cardPoints_dealer) {
			System.out.println("----You win----");
			System.out.println("BlackJack is over! Please play again ☆");
			return;
		}else{
			System.out.println("----You lose----");
			System.out.println("BlackJack is over! Please play again ☆");
			return;
		}

At the end

It was the first production since I started Java. The actual production time will be about 15 hours. The code has become long due to the immaturity of object-oriented design, but I would like to say that it should be extended. Thank you to everyone who commented and friends who gave me advice on Slack / Discord.

I haven't touched on Git yet, so I'm thinking of uploading this PG after Git becomes available.

Recommended Posts

[Production progress] BlackJack: 03
[Production progress] BlackJack: 01
[Production progress] BlackJack: 02
[Production progress] BlackJack: 04
Implemented "Blackjack".