//Code to copy
//main.cpp
#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
#include<fstream>
using namespace std;
int main()
{
srand(time(0));
const int CARDS=26;
const int size=2;
const int MIN=2;
const int MAX=14;
int i=0;
int score1=0,score2=0;
int player1card=0;
int player2card=0;
//create two 2D arrays
//index 0 represents player score
//index 1 represents the player drawn status
int hand1[CARDS][size];
int hand2[CARDS][size];
int player1Wins=0;
int player2Wins=0;
//set 0 indicate that all cards are not drawn
for(i=0;i<CARDS;i++)
{
hand1[i][1]=0;
hand2[i][1]=0;
}
cout<<setw(10)<<"Player1"
<<setw(10)<<"Player2"
<<setw(10)<<"Winner"<<endl;
for(i=0;i<CARDS;i++)
{
score1=rand()%(MAX-MIN)+MIN;
score2=rand()%(MAX-MIN)+MIN;
//check card is new
do
{
player1card=rand()%(26);
}while(hand1[player1card][1]!=0);
//set score1
hand1[player1card][0]=score1;
hand1[player1card][1]=1;
//check card is new
do
{
player2card=rand()%(26);
}while(hand2[player2card][1]!=0);
//set score2
hand2[player2card][0]=score2;
hand2[player2card][1]=1;
}
//print winners on console
for(i=0;i<CARDS;i++)
{
cout<<setw(10)<<hand1[i][0]
<<setw(10)<<hand2[i][0];
if(hand1[i][0]>hand2[i][0])
{
player1Wins++;
cout<<setw(10)<<"Player1"<<endl;
}
else
if(hand1[i][0]<hand2[i][0])
{
player2Wins++;
cout<<setw(10)<<"Player2"<<endl;
}
else
cout<<setw(10)<<"Tie"<<endl;
}
cout<<"Game Winner is ";
(player1Wins>player2Wins)?cout<<"Player1!"<<endl:cout<<"Player2!"<<endl;
system("pause");
return 0;
}
Sample Output:
C++ program This program involves writing a VERY simplified version of the card game War. You...
War—A Card game Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. War: Deal two Cards—one for the computer and one for the player—and determine the higher card, then display a message indicating whether the cards are equal, the computer won, or the player won. (Playing cards are considered equal when they have the same value, no matter what their suit is.) For this game, assume the Ace (value 1) is...
Please to indent and follow structure!!!!! Assignment 3 - The card game: War Due Date: June 9th, 2018 @ 23:55 Percentage overall grade: 5% Penalties: No late assignments allowed Maximum Marks: 10 Pedagogical Goal: Refresher of Python and hands-on experience with algorithm coding, input validation, exceptions, file reading, Queues, and data structures with encapsulation. The card game War is a card game that is played with a deck of 52 cards. The goal is to be the first player to...
I need to build the card game of War in C++. It will be a 2 player game. Each player will have their own deck of 52 cards. 2-10, Jack=11, Queen=12, King=13, Ace=14. Each player will draw one card from their deck. The player with the higher card wins both cards. If the card drawn is the same, then each player will draw 3 cards and on the 4th card drawn will show it. The player that shows the higher...
Program 4: C++ The Game of War The game of war is a card game played by children and budding computer scientists. From Wikipedia: The objective of the game is to win all cards [Source: Wikipedia]. There are different interpretations on how to play The Game of War, so we will specify our SMU rules below: 1) 52 cards are shuffled and split evenly amongst two players (26 each) a. The 26 cards are placed into a “to play” pile...
Complete a program In C#: some code is included, you edit the areas that have not been filled. For your C# program you will complete code that plays the War card game. In this game, the deck of cards is evenly divided among two players. The players are not allowed to look at the cards in their hand. On each round of the game, both players lay down the top card from their hand. The player with the higher value...
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...
I am playing a simplified version of the card game, "War," with my brother. We are playing with a subset of the deck, all of the numbered cards 2 through 10 (2:10). There are 4 cards of each number, resulting in 36 total cards in a single pile. First, I turn over a card. Next, he turns over a card. Whoever has the higher card wins and these "used" cards are discarded. If we turn over the same card, we...
C only (not C++) Write a C program that simulates a game. There are two players (called Player1 and Player2). At the start of the game, each player chooses a number from 1 to 10 (cannot be the same). Then, the program will generate a random number from 1 to 10. The game ends when either Player1 or Player2 hits the number generated by the program. Display the winning message for the winner. Example output: Player 1: 6 Player 2:...
4. In one version of the game played by a dealer and a player, 2 cards of a standard 52-card bridge deck are dealt to the player and 2 cards to the dealer. For this exercise, assume that drawing an ace and a face card (Jack, Queen and King for each shape) is called blackjack. If the dealer does not draw a blackjack and the player does, the player wins. If both the dealer and player draw blackjack, a tie...
Suppose, we have 3 players and they are playing a card game. In the card game, the deck contains 10 cards where there are 3 kings, 3 aces, and 4 jacks. Each player gets a card from the deck randomly. The winner of the game is determined based on the strength of the card where a king has 10 strength, an ace has 15 strength and a jack has 20 strength. Your task is to write a function called playgame()...