7 Replies - 264 Views - Last Post: 09 February 2018 - 02:44 PM Rate Topic: -----

#1 Galgurith   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 18

Crazy Eights Game

Posted 09 February 2018 - 02:19 PM

I am a brand new programmer and I am figuring out how to do the card game Crazy eights and I could use some assistance on what to do.

Right now I am trying to figure out how to place 1 card face up from the deck and play it into the discard pile.

I think i figured out how to draw 1 card from the back and place it into the Discard pile. But I am unsure how to display said card

For example:
I draw 1 Card from the Deck and place it into the Discard pile but I don't know what that card is like ?????? Ace of spades or whatever.


//TODO: Place one card Face up
DiscardDeck.push_back(Deck.back);
Deck.pop_back();
cout << "Select a Card:" << endl;
//cin >> DiscardDeck;


I am also trying to figure out how to do this

//Add function where it checks if he has any special cards if dont have any card buy a card and end your turn.

//Play more than 1 card unless their special cards.

Is This A Good Question/Topic? 0
  • +

Replies To: Crazy Eights Game

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14045
  • View blog
  • Posts: 56,201
  • Joined: 12-June 08

Re: Crazy Eights Game

Posted 09 February 2018 - 02:23 PM

I would figure your 'card' object would have a 'print' which would print out the suit and value. This means your 'deck' object would contain a collection of 'card' objects and you should be able to print out what it was.
Was This Post Helpful? 1
  • +
  • -

#3 Galgurith   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 18

Re: Crazy Eights Game

Posted 09 February 2018 - 02:25 PM

View Postmodi123_1, on 09 February 2018 - 02:23 PM, said:

I would figure your 'card' object would have a 'print' which would print out the suit and value. This means your 'deck' object would contain a collection of 'card' objects and you should be able to print out what it was.



Okay so what your saying is I was missing the print function of what card that i picked up and was placed into the Discard pile.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14045
  • View blog
  • Posts: 56,201
  • Joined: 12-June 08

Re: Crazy Eights Game

Posted 09 February 2018 - 02:27 PM

Indeed. Seems the most logical place to put it.. in the 'card' class.
Was This Post Helpful? 1
  • +
  • -

#5 Galgurith   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 18

Re: Crazy Eights Game

Posted 09 February 2018 - 02:29 PM

View Postmodi123_1, on 09 February 2018 - 02:27 PM, said:

Indeed. Seems the most logical place to put it.. in the 'card' class.


I am not quite sure if this is right.
But i am doing a text based C++ crazy eights game.

I got my shuffle working my draw cards working now i just want to figure out how to draw 1 card from the deck and display that card.
	//TODO: Place one card Face up
	DiscardDeck.push_back(Deck.back);
	Deck.pop_back();
	cout << "Select a Card:" << endl;

	printf("Select a card");
:code:

This is the code i got so far for what i did but if i did something wrong let me know.

This post has been edited by modi123_1: 09 February 2018 - 02:30 PM
Reason for edit:: In the future use the [code] button in the editor.

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14045
  • View blog
  • Posts: 56,201
  • Joined: 12-June 08

Re: Crazy Eights Game

Posted 09 February 2018 - 02:30 PM

What's your DECK class looking like?
How about a CARD class?
Was This Post Helpful? 1
  • +
  • -

#7 Galgurith   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 18

Re: Crazy Eights Game

Posted 09 February 2018 - 02:33 PM

View Postmodi123_1, on 09 February 2018 - 02:30 PM, said:

What's your DECK class looking like?
How about a CARD class?


I am not using any sorts of classes right now but this is my code that i got so far for my entire Crazy Eights game

https://hastebin.com/ahadayebux.go
Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg   User is online

  • member icon

Reputation: 5470
  • View blog
  • Posts: 17,022
  • Joined: 25-December 09

Re: Crazy Eights Game

Posted 09 February 2018 - 02:44 PM

Quote

I am not using any sorts of classes right now

Yes you are. A struct is basically the same as a class.

I suggest you get rid of all of those global variables and make them local to a function.

typedef struct
{
    CardType type;
	CardNumber number;

What is a CardType and a CardNumber/


By the way you don't need the typedef in a C++ program. All you need is :
struct Card
{
...
};



Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1