unexpected output for deck of cards

i am not sure why the output would display Jack for 11 and above?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <vector>
#include <string>
#include <map>

class Deck{
    public:
        
        std::vector<int> suit_num = {1,2,3,4,5,6,7,8,9,10,11,12,13};
        std::vector<std::string> suit_name = {"spades", "clubs", "hearts", "diamonds"};
        std::map<std::string, std::vector<int>> cards;
        Deck(){
            for (auto name: suit_name){
                cards.insert(std::pair<std::string, std::vector<int>>(name, suit_num));
            }
        }
        
        void display(){
            std::string num_display;
            for (auto name: suit_name){
                for (auto num: suit_num){
                    if (num == 1)
                        num_display = "Ace of";
                    else if (num == 11)
                        num_display = "Jack of";
                    else if (num == 12)
                        num_display == "Queen of";
                    else if (num == 13)
                        num_display == "King of";
                    else
                        num_display = std::to_string(num);
                    std::cout << num_display << ' ' << name << ", ";
                }
                std::cout << "\n\n";
            }
        }
};


int main(){
    Deck deck;
    deck.display();
}


Ace of spades, 2 spades, 3 spades, 4 spades, 5 spades, 6 spades, 7 spades, 8 spades, 9 spades, 10 spades, Jack of spades, Jack of spades, Jack of spades,

Ace of clubs, 2 clubs, 3 clubs, 4 clubs, 5 clubs, 6 clubs, 7 clubs, 8 clubs, 9 clubs, 10 clubs, Jack of clubs, Jack of clubs, Jack of clubs,

Ace of hearts, 2 hearts, 3 hearts, 4 hearts, 5 hearts, 6 hearts, 7 hearts, 8 hearts, 9 hearts, 10 hearts, Jack of hearts, Jack of hearts, Jack of hearts,

Ace of diamonds, 2 diamonds, 3 diamonds, 4 diamonds, 5 diamonds, 6 diamonds, 7 diamonds, 8 diamonds, 9 diamonds, 10 diamonds, Jack of diamonds, Jack of diamonds, Jack of diamonds,
Last edited on
You've put == for your num_display assignments of "Queen of" and "King of".
oh duh, lol

thanks
Topic archived. No new replies allowed.