programming language c++
programming language c++
#include<iostream> #include<string.h> #include <cstdlib> #include <ctime> #include <list> using namespace std; void shuffleCards(string cards[]){ for(int i=0; i<50; i++){ int index = rand() % 52; string temp = cards[0]; cards[0] = cards[index]; cards[index] = temp; } } int getValueOfCard(string card){ if(card[1]=='1' || card[1]=='J' || card[1]=='Q' || card[1]=='K') return 10; else if(card[1]=='A') return 11; else{ string str = card.substr(1,2); return stoi(str); } } int main(){ string colors[] = {"S","D","H","C"}; string values[] = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; string cards[52]; for(int i=0; i<4; i++) for(int j=0; j<13; j++) cards[i*13+j] = colors[i]+values[j]; shuffleCards(cards); /*Game starts here*/ int player_points = 1000; list<string> dealer_cards; list<string> player_cards; int cardsIndexTracker = 0; int dealer_score = 0; int player_score = 0; string card; int risk_points; cout << "Your points are: "<<player_points<<endl; cout <<"Enter the risk points: "; cin >> risk_points; while(risk_points > player_points){ cout << "Risk points value should be less than your points("<<player_points<<")!"<<endl; cout << "Enter the risk points: "; cin >> risk_points; } while(true){ card = cards[cardsIndexTracker++]; dealer_cards.push_back(card); dealer_score += getValueOfCard(card); card = cards[cardsIndexTracker++]; dealer_cards.push_back(card); dealer_score += getValueOfCard(card); card = cards[cardsIndexTracker++]; player_cards.push_back(card); player_score += getValueOfCard(card); card = cards[cardsIndexTracker++]; player_cards.push_back(card); player_score += getValueOfCard(card); cout << "Player score: "<< player_score<<endl; while(player_cards.size() < 5){ char ch; cout << "Another card? "; cin >> ch; if(ch=='n') break; card = cards[cardsIndexTracker++]; player_cards.push_back(card); int value = getValueOfCard(card); if(value==11 && player_score > 21) player_score += 1; else player_score += value; cout << "Player score: "<< player_score<<endl; } while(dealer_cards.size() < 5 && dealer_score < 16){ card = cards[cardsIndexTracker++]; dealer_cards.push_back(card); dealer_score += getValueOfCard(card); } if(player_score > dealer_score) player_points += risk_points; else if(dealer_score > player_score) player_points -= risk_points; if(player_points > 0){ dealer_cards.clear(); player_cards.clear(); dealer_score = 0; player_score = 0; cardsIndexTracker = 0; cout << "Your points are: "<<player_points<<endl; char want_to_play_more; cout << "Do you want to play more(y or n): "; cin >> want_to_play_more; if(want_to_play_more=='n'){ cout << "Your points are "<<player_points<<endl; break; } cout <<"Enter the risk points: "; cin >> risk_points; while(risk_points > player_points){ cout << "Risk points value should be less than your points("<<player_points<<")!"<<endl; cout << "Enter the risk points: "; cin >> risk_points; } shuffleCards(cards); }else{ cout << "Your points are: "<<player_points<<endl; break; } } return 0; }
programming language c++ programming language c++ 1:25 #WW # 53% You may, if you wish, work...
programming language c++
its a project if anyone can help me it's will be
appreciated thnk u.
u have to create a code based on the information im giving
u
you can do it in 1 or 2 day i can wait
1:26 #WW 2.53% Example: A user starts with 1000 points. Game #1 - user chooses to risk 200 points. User wins game (beats the dealer). User now has 1200 points. Game #2 - user chooses to risk 500...
Create a simplified Blackjack game using the Deck and Card classes (download the attached files to start). There is also a "TestCard" class that creates a Deck and runs some simple code. You may choose to use this file to help you get started with your game program. 1) Deal 2 cards to the "player" and 2 cards to the "dealer". Print both the player's cards, print one of the dealer's cards. Print the total value of the player's hand. 2) Ask...
Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...
Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....
Need a blackjack code for my assignment its due in 3 hours: it has to include classes and object C++. Create a fully functioning Blackjack game in three separate phases. A text based version with no graphics, a text based object oriented version and lastly an object oriented 2D graphical version. Credits (money) is kept track of throughout the game by placing a number next to the player name. Everything shown to the user will be in plain text. No...
How do I start this c++ code homework? Write a code in C++ for a BlackJack card game using the following simplified rules: Each card has a numerical value. Numbered cards are counted at their face value (two counts as 2 points, three, 3 points, and so on) An Ace count as either 1 point or 11 points (whichever suits the player best) Jack, queen and king count 10 points each The player will compete against the computer which represents...
You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...
Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...
You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. You may complete this project individually or in a group of no more than 2 other people. Requirements do not change if you choose to complete the project individually or as part of a group. Customer-specific requirements You can create...
in c programming and c++filed
Exercise 1: A Game of guessing number Set the default upper and lower limits to be 1-100, and ask you to guess a number. If you do not guess the correct number, the program will nicely" automatically adjust the upper or the lower limits to save your day until you guess it. 2 0 12. 51 - 100 3 2 51 74 22 65 74 85 2 71 74 3 . 2 73 74 75...