0

Yoo, I'm new to the site so please forgive me if I'm a little unspecific (Although I will try to be as specific as I can).

A little intro... Recently I've been really hitting the programming, I'm trying make a BlackJack game so that I can develop my knowledge and build upon the knowledge I already have from books. I've attempted to plan the program out in Dia so that I have an idea on the programs flow (link at the bottom).

To cut to the chase...I've got a vector called 'suit' which contains 13 'Cards' (Screenshot of my program output available at the bottom). Each card has an enum for its rank and suitType, what I'd really like is the ability to print out its suite type and rank as a string. I have done a little experimentation and reading, but the truth is I'm not sure where to start. I've read something about Maps being useful somewhere. blackjack-diagram program-output

  • A map or a simple function will do the trick. Do you have a specific question about how to implement either? – cdhowie Apr 27 '17 at 21:52
  • Yeah, how would I implement a map? I'm going to have to do some reading as I have virtually no experience using them. – Joshua Walley Apr 27 '17 at 21:53
  • 1
    See the [`std::map`](http://en.cppreference.com/w/cpp/container/map) documentation. Basically you would be looking at an `std::map` or `std::map`. – cdhowie Apr 27 '17 at 21:54
  • @JoshWalley You don't need to implement a map, when you have, one, perfectly good, `std::map` available. – Algirdas Preidžius Apr 27 '17 at 21:54
  • @cdhowie Nowadays, I would recommend using `std::string` instead of `const char*`. – Algirdas Preidžius Apr 27 '17 at 21:56
  • Ah right ok I'll get on that. Cheers for such a fast reply. – Joshua Walley Apr 27 '17 at 21:57
  • Unless your enumerated type has funky values (i.e., not contiguous), a map is overkill. What you need is an array, and you can use the value of the enum as an index into the array. – Pete Becker Apr 27 '17 at 22:15
  • I'm not so sure about that. Technically its working correctly, but I really want to be able to print its SuitType to the screen for clarity. So instead of printing this:- Card 0 Suit:0 Card 0 Rank: 0 (It needs to be more like "Card 0 - Ace, Suit 0 - diamonds") – Joshua Walley Apr 27 '17 at 22:41

0 Answers0