CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Angry Need Help!!! Creating a Rummikub console app.

    I just started to write this program. Right now I have 2 main classes- class Rummikub which contains a pool of 106 tiles which I declared as a private data member- string tiles[106]. I also have another class, class Hand. Hand will need to maintain a dynamic "array" of some sort like a vector which will increase and/or decrease in size. The "hand" is the player's current hand of tiles that they have. This "Hand" class contains as private data members "vector<string> vecHand" and "vector<string>::iterator it" as the iterator.

    I'm needing this string vector to be able to access the private data member of class Rummikub, which is string tiles[106]. I know I can do this by declaring a friend of the class. I'm having a hard time with this and would appreciate any feedback on how to do this, not necessarily using the "friend" idea. I'm not that familiar with "friends" so I may have totally messed that up in the code below. Anything anyone has is appreciated. Any ideas on how to accomplish this would be terrific. Below are snippets of my code. Thanks a bunch for the help!!

    class Rummikub {
    friend class Hand; //class Rummikub is friends with class Hand
    public:
    ~Rummikub();
    Rummikub(); //constructor sets and shuffles the tiles
    string itos(int); //custom function
    private:
    string tiles[106];
    };

    class Hand {
    friend class Rummikub; //class Hand is friends with class Rummikub
    public:
    Hand();
    void checkForMoves();
    void dropTile();
    string accessTile();
    private:
    vector<string> vecHand;
    vector<string>::iterator it;
    };
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured