The program imitates a gambling card game. The program shows you three cards, then the program interchange them, and if you can guess correctly where a particular card is, you win.

Here is some sample interaction with the program:
Card 1 is the 7 of clubs
Card 2 is the jack of hearts
Card 3 is the ace of spades
I’m swapping card 1 and card 3
I’m swapping card 2 and card 3
I’m swapping card 1 and card 2
Now, where (1, 2, or 3) is the ace of spades?
If the user insert 3
The program will print” sorry, you lose.”


Solution hints:
Implement the previous program using structure, this structure represent the data of Card (number and suit), so the structure uses separate members to hold of the number of the card and suit. The number runs from 2 to 14, where 11, 12, 13 and 14 represent the jack, queen, king, and ace, respectively. The suit runs from 0 to 3, where these four numbers represent clubs, diamonds, hearts, and spades.

I take it this is your homework? Well perhaps if you show some effort, then we will consider helping...If we were to just give you the answer, what good would you achieve from that?

Edited 6 Years Ago by The ICE Man: n/a

i already started it but cant do it all alone,, and it is a project worth 10%.. and it is so important.. plz if u can help me i will be very thankful

i already started it

Prove it. Just saying you started it does not mean we're going to write it for you.

plz if u can help me i will be very thankful

We will help. But you have to explain what you need help with. Details, specific questions, those we can answer. And code.

Read the Member Rules...

#include <iostream>
class Card
  {
    int number;
    string suit;

      public:
        Card () {};
        ~Card () {};
        Card(int n,string s) , number(n), suit(s) {};
        Card& operator= (const Card d) 
		{          
            number=d.number;
            suit=d.suit;
          }
        friend bool operator== (const Card c,const Card d) 
		{
            return (c.number==d.number) && (c.suit==d.suit);
          }
        friend ostream& operator << (ostream& o,Card d) {return o<<d.number << endl << d.suit;}            
  };

void SwapCards(Card&,Card&);

void main ()
  {
    Card one(4,"spades");
    Card two(6,"clubs");    
    SwapCards(one,two);
  }

void SwapCards(Card& a,Card& b)
  {
    Card chair;
    chair=a;
    a=b;
    b=chair;
  }

this was a start but lots of errors, and cant complete it.. plzzzzz any help

Edited 6 Years Ago by WaltP: Added CODE Tags

friend bool operator== (const Card c,const Card d) 
{
return (c.number==d.number) && (c.suit==d.suit);
}
friend ostream& operator << (ostream& o,Card d) {return o<<d.number << endl << d.suit;}

What's going on right here?

This article has been dead for over six months. Start a new discussion instead.