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.

plz guys any help,, this is a project for me and i have the due date on thursday, i need any help plzz

#include <iostream>

using namespace std;

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&);

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

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

Hope this will get you started..

commented: Don't hand out code willy-nilly. You just gave away half the assignment. What does that teach? Nothing. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.