confused on classes

I'm doing the playing card program. The step I'm on is to sort the deck after shuffling it, so I can then perform a search.

the private member "int initIndex" is what I need to compare card to card to sort them

I made the dumb move of trying to copy cardSet to sortSet and then compare the two for a linear sort, obviously not work.

The sorting function is going to be under the Deck class. Question is, how can I access the initIndex of a cardSet element? Or is there a better way to sort these cards after a shuffle?

here's my two classes:

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class Card
{
    private:

        int initIndex;
        int suit;
        int faceValue;
        char sSymbol;
        string vSymbol;
        bool isHeld;
        bool isVisible;
        bool debugging;
    
    public:

        Card();
        Card(int , int , int , bool = false );
        ~Card();

        void display() const;
        int whatSuitNumber() const {return suit; }
        char whatSuitSymbol() const {return sSymbol; }
        int whatFaceValue() const {return faceValue; }
        string whatPip() const {return vSymbol; }
        bool inDebugMode() const {return debugging; }
        
        void initialize( int , int , int , bool = true );
        void pickUp( bool = false );
        void play( bool = false );
        void show() {isVisible = true; }
        void hide() {isVisible = false; }
        void setDebug(bool dBug) {debugging = dBug; }

};


class Deck
{
    private:

        Card cardSet[DECK_SIZE];
        Card sortSet[DECK_SIZE];
        bool deBugging;
        int OS;             // the current operating system
        //int value[A_SIZE];
        void clearScreen() const;

    public:

        Deck();
        ~Deck();

        void display( int = 0 );
        void displayCard( int = 0 );
        bool inDebugMode() const {return deBugging; }

        void refresh( bool = false );
        void revealCard(int thisCard) { cardSet[thisCard].show(); }
        void revealAll();
        void hideCard(int thisCard) { cardSet[thisCard].hide(); }
        void hideAll();
        void shuffle( int );
        void deal( int = 1, bool = false );
        void takeCard(int card, bool up = false) { cardSet[card].pickUp(up); }
        void putCard (int card, bool up = false) { cardSet[card].play(up); }
        void setDebug(bool dBug) {deBugging = dBug; }

        //void GraphIt(string ) const;// "graphs" values
        int linearSearch(int ) const; //finds the first instance of valu
        int binarySearch(int ) const;
	void selectionSort(Deck[], Deck[]);	// sorts the list and/or displays process
	void bubbleSort(Deck);		// sorts the list and/or displays process

};


thanks.
Last edited on
Topic archived. No new replies allowed.