5 Replies - 3715 Views - Last Post: 03 May 2010 - 11:46 AM Rate Topic: -----

#1 deadelgabar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-May 10

c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 10:39 AM

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
Im swapping card 1 and card 3
Im swapping card 2 and card 3
Im 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.

sorry for being anoyying, but it is very important

Is This A Good Question/Topic? 0
  • +

Replies To: c++ card game,, just need a start up, and a little hint

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,496
  • Joined: 23-August 08

Re: c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 10:48 AM

Don't double post. I deleted the first topic you created.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
Was This Post Helpful? 1
  • +
  • -

#3 deadelgabar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-May 10

Re: c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 11:10 AM

#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;
  }


that what i have done, plz any help
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 770
  • View blog
  • Posts: 2,249
  • Joined: 20-March 10

Re: c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 11:17 AM

Dude there is no way that will work
small help
you need to #include <string>

but then there is still no way that it'll work but it helps a little.

I cant write the program for you or I will get in trouble.

but what you need to do is
set up something like this example

#include <string>
#include <iostream>
using namespace std;

class Dog
{

//private variables
int age,weight;
string color;

//public variables
public:

void bark(){ cout<<"WOOF!"<< endl;}
void setAge(int yrs) {age =yrs;}
void setWeight(int lbs) {weight = lbs;}
void setColor(string clr) {color =clr;}
int getAge() {return age;}
int getWeight() {return weight;}
string getColor() {return color;}

};

int main()
{
//main program staements
Dog fido;
fido.setAge(3);
fido.setWeight(15);
fido.setColor("brown");

cout << "Fido is a "<<fido.getColor()<<" dog"<<endl;

cout << "Fido is "<<fido.getAge()<<" years old"<<endl;

cout << "Fido weighs "<<fido.getWeight()<<" pounds"<<endl;

// regular output method
fido.bark();

return 0;
}





This post has been edited by snoopy11: 03 May 2010 - 11:43 AM

Was This Post Helpful? 0
  • +
  • -

#5 joesyuh  Icon User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 174
  • Joined: 30-September 08

Re: c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 11:24 AM

Could you please use the code tags when you put code in to the forums. It makes it easier to read these threads and your code.

Also could you post any compiler/logic/runtime errors you receive? I cant read your mind to help you.
Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: c++ card game,, just need a start up, and a little hint

Posted 03 May 2010 - 11:46 AM

This isn't a free homework forum. You seem to think that after dumping token code here, we'll do the rest of the program for you...

When you ask for help here, you need to have a clear question in mind. You should be able to explain how you have attempted to answer your question, and what precisely prevents you from answering it.

If you just dump an assignment along with token code, we aren't going to take it up and finish it for you...
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1