card game: just need to know why its not compiling...

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: card game: just need to know why its not compiling...

 
0
  #11
Oct 10th, 2008
Oh. I think the output of your program is confusing you... When you print an enum value ( using iostream operator<< ) it prints the integer value of the enum.. so when your program outputs:

Player one has:
31

this is a 3, and a 1 stuck together: not a 31.

so that's the 3 of clubs... output a space inbetween the two numbers =).. eg.
  1. cout<<hand1[s].Value<<" ";
  2. cout<<hand1[s].Type<<endl;
to print an enums "tag", you pretty much have to do:
  1. switch ( value )
  2. {
  3. case Card::diamond:
  4. std::cout << "diamond";
  5. break;
  6. case Card::club:
  7. ...etc..
  8. }
Last edited by MattEvans; Oct 10th, 2008 at 6:57 pm.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 11
Reputation: avillachandok is an unknown quantity at this point 
Solved Threads: 0
avillachandok avillachandok is offline Offline
Newbie Poster

Re: card game: just need to know why its not compiling...

 
0
  #12
Oct 11th, 2008
ok. i got the program to run finally.
now i've this extention to the program to make an algorithm(written)..
so this is the question:

Create an Object Oriented design for a two player card game.
Repeat 26 times(each time is a turn)
play one card from each hand to the table.
compare the two cards
if they have the same no return them to the bottom of each hand
if one is larger take both cards and put them on the bottom of the hand from which the larger card came.

declare the hand with the most cards the winner
deal with ties
end game.

so for the design i will change the array into a linked list..or some other data structure in which i can access the top of the pile and still be able to count the size of the stack.
make a turn method in the deck class and pass in an int parameter so the loop inside knows how many times to run.
in the loop compare the top values of the two player lists and accordingly perform moving both cads back in their piles(if tied), move both the compared cars (to the pile which had teh bigger card) etc...
at the end of the loop return to the main function and count the length and declare a winner or deal again until the lenth of the array is unequal. and then declare winner.

so my extention to the program is:
Add at the start of the game the ability for theuser to play two different ways:
1. the method described above(so i'll put all of the above in a switch format)
2. the following changes/additions are made:
Cards are played on to the table out of the players hands.
That instead of 26 turns, the game continues until at any point in the game if a player has less than 5 cards in their hand they are declared the loser, or one of the players concedes.
If during a turn there is a tie, take three additional cards from each hand and put them on the table, and compare the last of the three with the larger number getting all of the cards played during that turn. This may have to be repeated if the last of the three in each hand is the same number.

So my problem is how do i design this part? specifically what do they mean cards are played on to the table of the the players hand??do i need a player class??
can I use the same turn method or do i have to make another one..
really need help thanks.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC