1-Write a shell script to play the card game Blackjack. There must be one dealer and at least one player. Name the program blackjack.sh. You will need to: use arrays and functions. determine how to ensure that a card which is dealt to one user is removed from the pack so that it is not available to other users. make the program user friendly.
1-Write a shell script to play the card game Blackjack. There must be one dealer and at least one player. Name the program blackjack.sh.
You will need to:
- use arrays and functions.
- determine how to ensure that a card which is dealt to one user is removed from the pack so that it is not available to other users.
- make the program user friendly.
Rules of the game
At the start of a blackjack game, the players and the dealer will receive two cards each. The players' cards are normally dealt face up, while the dealer has one face down (called the hole card) and one face up.
The aim of the game is to accumulate a higher point total than the dealer, but without going over 21. You compute your score by adding the values of your individual cards.
The cards 2 through 10 have their face value, J, Q, and K are worth 10 points each, and the Ace is worth either 1 or 11 points (player's choice).
The best possible blackjack hand is an opening deal of an ace with any ten-point card. This is called a "blackjack", or a natural 21, and the player holding this automatically wins unless the dealer also has a blackjack. If a player and the dealer each have a blackjack, the result is a push for that player. If the dealer has a blackjack, all players not holding a blackjack lose.
After the cards have been dealt, the game goes on with each player taking action - in clockwise order starting to dealer's left.
Each player can keep his hand as it is (stand) or take more cards from the deck (hit), one at a time, until either the player judges that the hand is strong enough to go up against the dealer's hand and stands, or until it goes over 21, in which case the player immediately loses (busts).
In most places, players can take as many cards as they like, as long as they don't bust (exceed 21).
When all players have finished their actions, either decided to stand or busted, the dealer turns over his hidden hole card.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps