C++: Create a class named PlayingCard. The class contains four fields for a standard playing card: a value in numeric (e.g. 12) . a value
C++: Create a class named PlayingCard. The class contains four fields for a standard playing card:
- a value in numeric (e.g. 12) .
- a value in string format (e.g. "Queen").
- a suit in numeric (e.g. 1).
- a suit in string format (e.g. "spade").
Each PlayingCard is assigned its values upon construction.
Write a main() function that plays a card game where the objective is to have the greatest number of pairs; a pair is composed of two cards of the same value in different suits. Randomly deal five cards each to a player and to a computer. Make sure there are no duplicate cards, as would be the case using a standard playing card deck. (For example, a deck can contain four fives and 13 spades, but only one five of spades.) Count the number of matching cards for the player and for the computer, and announce a winner or a tie.
For this game assume that a pair beats no matching cards, three of a kind beats a pair, four of a kind beats three of a kind, and five of a kind beats four of a kind. Card values do not affect the outcome-for example, two eights are no better than two sevens. Also assume two pairs are no better than a pair.
Sample run Player's cards: Card is King of hearts Card is 7 of hearts Card is 9 of spades Card is 8 of clubs Card is Ace of spades Computer's cards: Card is 5 of clubs Card is 8 of spades Card is 2 of diamonds Card is 9 of clubs Card is 6 of hearts Player has no pairs Computer has no pairs It's a tie ==================== Player's cards: Card is 10 of diamonds Card is 2 of hearts Card is 4 of hearts Card is King of diamonds Card is 2 of diamonds Computer's cards: Card is Ace of hearts Card is 9 of diamonds Card is 4 of diamonds Card is 5 of diamonds Card is King of clubs Player has 2 cards of the same value Computer has no pairs Player wins ==================== Player's cards: Card is Queen of clubs Card is Jack of hearts Card is 6 of spades Card is 5 of diamonds Card is 5 of clubs Computer's cards: Card is 4 of hearts Card is 8 of clubs Card is Jack of spades Card is King of clubs Card is 4 of clubs Player has 2 cards of the same value Computer has 2 cards of the same value It's a tie
Note: Please don't to use #include<bits/stdc++.h>. Use simple class, Inheritance, Polymorphism, and Virtual Functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started