| | |
card game: just need to know why its not compiling...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
to print an enums "tag", you pretty much have to do:
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.
C++ Syntax (Toggle Plain Text)
cout<<hand1[s].Value<<" "; cout<<hand1[s].Type<<endl;
C++ Syntax (Toggle Plain Text)
switch ( value ) { case Card::diamond: std::cout << "diamond"; break; case Card::club: ...etc.. }
Last edited by MattEvans; Oct 10th, 2008 at 6:57 pm.
Plato forgot the nullahedron..
•
•
Join Date: Oct 2008
Posts: 11
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- card game (Java)
- Playing cards (C++)
Other Threads in the C++ Forum
- Previous Thread: RichEdit subclassing problem, can't call Default Proc.
- Next Thread: Number Guesssing Game Help
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






