Highest Card Wins

Hey guys, I am working on an assignment that is using structures.
Basically all I need to do is assign one card to the "player" and one card to the "computer". Then check to see which card value is greater and that be the winner.
I also need to use random number generator to get the card number and suit for both computer and user. If they have the same card they need to both draw another. Also I should add a loop to allow them to play again.
I can get most of this down, just need help. My instructor isn't that helpful, nor is available for questions "Great class...."

Here is what I got to work with.
I figured I could use srand/rand to get random card # and suit.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;
const int clubs = 0; //suits
const int diamonds = 1;
const int hearts = 2;
const int spades = 3;
const int jack = 11; //face cards
const int queen = 12;
const int king = 13;
const int ace = 14;
////////////////////////////////////////////////////////////////
struct card
{
	int number; //2 to 10, jack, queen, king, ace
	int suit; //clubs, diamonds, hearts, spades
};
////////////////////////////////////////////////////////////////
int main()
{
	card temp, chosen, prize; //define cards
	int position;
	card card1 = { 7, clubs }; //initialize card1
	cout << "Card 1 is the 7 of clubs\n";
	card card2 = { jack, hearts }; //initialize card2
	cout << "Card 2 is the jack of hearts\n";
	card card3 = { ace, spades }; //initialize card3
	cout << "Card 3 is the ace of spades\n";
	prize = card3; //copy this card, to remember it
	cout << "Iím swapping card 1 and card 3\n";
	temp = card3; card3 = card1; card1 = temp;
	cout << "Iím swapping card 2 and card 3\n";
	temp = card3; card3 = card2; card2 = temp;
	cout << "Iím swapping card 1 and card 2\n";
	temp = card2; card2 = card1; card1 = temp;
	cout << "Now, where (1, 2, or 3) is the ace of spades? ";
	cin >> position;
	switch (position)
	{
	case 1: chosen = card1; break;
	case 2: chosen = card2; break;
	case 3: chosen = card3; break;
	}
	if(chosen.number == prize.number && // compare cards
		chosen.suit == prize.suit)
		cout << "Thatís right! You win!\n";
	else
		cout << "Sorry. You lose.\n";
	return 0;
}
Oh and by the way, I am not asking anyone to do this for me. Just when I post a code segment and have a question I was just wondering if you could point me in the right direction.
Topic archived. No new replies allowed.