![]() |
|
#1
|
|||
|
|||
High card evaluatorI am creating a program in c++ that has the user enter 4 cards and I need it to display the high card any help or advice would be great thanks
|
|||
|
#2
|
|||
|
|||
Re: High card evaluatorQuote:
Here's a possibility: Suppose we have some scheme by which the user can enter a card name (a string). The program will have a way of assigning a value (a positive integer) to a card with a valid name. Note that there must be a way of validating the card name. The validation functionality can be implemented as a separate function or can be made part of the code that assigns the numerical value. Code:
Regards, Dave Footnote: This is a very general expression of a plan. Maybe it's too much. Maybe it's not enough. For example, if you don't need to keep track of the suit, maybe you just need to get a rank from the user (1 through 13, or one of the set {2, 3,...10, J, Q, K, A}. If you have to keep track of suits, there is the question of whether all cards of the same rank have the same value. (Does the ace of spades have a higher value than the ace of clubs, for example.) If suits are irrelevant, then you may need to consider what to do if two cards of equal value are drawn. In fact, it's not clear whether the four cards "drawn" by the program are necessarily distinct. Once we start thinking about things, then the following "issues" arise: Are the cards "drawn" from a deck? How many cards are in the deck? Is a card replaced in the deck after being drawn? Or what? Is the program required to keep track of all cards drawn (so that it can check for duplicates)? Or what? See what I did here? I started writing code (pseudo-code in this case) before I actually had a program specification. I don't think it was necessarily wasted effort, but I think that writing a program specification should precede writing code. In this case (since we don't know what your actual assignment is), I just threw out some things in the pseudo code that can act as a template for the actual program. Details may be added (or removed), depending on the program specification. So: The real bottom line (before you write the plan) is to describe, exactly, what the user input is required to be and what you should do with the input to get the output. __________________
Sometimes I just can't help myself... Last edited by davekw7x : 18-Feb-2012 at 07:22.
|
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Credit Card Processing For High, Domestic Bank Backed | HughH1 | eCommerce / Merchant Account Forum | 0 | 07-Feb-2012 17:26 |
| Learning Java - Need Tips | LocalTech | Java Forum | 5 | 11-Aug-2011 07:56 |
| Sound card driver setup | swazi | Computer Hardware Forum | 4 | 04-Sep-2004 09:27 |
| 6 Parties for Every Credit Card Transaction | Corey Bryant | eCommerce / Merchant Account Forum | 0 | 16-Aug-2004 15:28 |
| Card Game Help! | Pravda | C++ Forum | 4 | 28-May-2004 08:40 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The