Pretty much creating a card game for class. Not looking for straight up answers but a better understanding to learn the material of why im getting the problem i am. Thanks for any help i can get. Heres the problem:
Create a card game called flash card using struct data structure when each player draws three cards for random numbers (1-4) as Diamond, Spade, Clubs and Hearts respectively and another set of random numbers of card value 1-13. The cardScore is defined as highest (say cardScore =100 for three A s’ (cardValue 1), followed by three Jacks (cardValue 11) (say cardScore 90), followed by three Kings (cardValue 13)(say cardScore =80) and then three Queens (cardValue 12)(say cardScore = 70). Other than the above said combinations the cardScore is defined by the sum of the cardValue of each draw. The player which has the highest score after three draws win. Display the cards drawn by each player and the cardScore and the winner
#include "pch.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
using namespace std;
class Values
{
public:
string cardFace;
int cardValue;
int cardFaceRng;
int cardValueRng;
private:
};
//declaring functions
void setCardFaceRandom();
void setCardValueRandom();
void setCardFace();
void setCardValue();
int main()
{
Values v;
for (int i = 0; i < 3; i++)
{
v.cardFaceRng = rand() % 3 + 1;
v.cardValueRng = rand() % 14 + 1;
//setCardFaceRandom();
//setCardValueRandom();
setCardFace();
setCardValue();
cout << v.cardFace << " " << v.cardValue << endl;
}
system("pause");
return 0;
}
void setCardFace() {
Values v;
switch (v.cardFaceRng)
{
case 0:
v.cardFace = "Diamond";
break;
case 1:
v.cardFace = "Spade";
break;
case 2:
v.cardFace = "Club";
break;
case 3:
v.cardFace = "Hearts";
break;
}
cout << v.cardFace;
}
void setCardValue() {
Values v;
switch (v.cardValueRng)
{
case 0:
v.cardValue = 2;
break;
case 1:
v.cardValue = 3;
break;
case 2:
v.cardValue = 4;
break;
case 3:
v.cardValue = 5;
break;
case 4:
v.cardValue = 6;
break;
case 5:
v.cardValue = 7;
break;
case 6:
v.cardValue = 8;
break;
case 7:
v.cardValue = 9;
break;
case 8:
v.cardValue = 10;
break;
case 9:
v.cardValue = 11;
break;
case 10:
v.cardValue = 12;
break;
case 11:
v.cardValue = 13;
break;
case 12:
v.cardValue = 14;
break;
}
cout << v.cardValue;
}
void setCardFaceRandom()
{
Values v;
v.cardFaceRng = rand() % 3 + 1;
}
void setCardValueRandom()
{
Values v;
v.cardValueRng = rand() % 14 + 1;
}