?
Solved

class help

Posted on 2005-03-24
4
Medium Priority
?
229 Views
Last Modified: 2010-04-23
im having some trouble with class programming.

im trying to create a poker simulator, so ill use that as an example.

i have the table class, clsTable, which calls other classes like clsDealer, and clsPlayer

the problem that im having is i have trouple manipulating data between classes, like when i want to deal cards.  the deal() function is held under the Dealer class, but it gives cards to the Player class

so all in all, the player class does not know that the dealer class exists, and visa versa.  obviously i cant create a new player class under the dealer class, becuase that will be a different instance than when i initially created it in the table class.

i can post code, but i think this can be solved without it.  let me know, and thanks in advance.
0
Comment
Question by:bramsquad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Dabas earned 1000 total points
ID: 13627472
Hi bramsquad:

Did you already write the deal function? What does it return, just a card?
Do you have a main class, or form that is the intermediary between the classes?
The way I see it, that class would consist of an arraylist of players and a dealer.

You would then have something like:

Dim CurrentPlayer as clsPlayer
Dim Dealer as clsDealer
.....

CurrentPlayer.Cards.Add(Dealer.Deal())
....


Dabas
0
 
LVL 8

Author Comment

by:bramsquad
ID: 13629447
well, i have the form which has the table on it.  when the form loads it calls clsTable.

what i was thinking of doing would be to call all the functions when events occur on the form.

so when someone wants to start a game, they click the button and it would envoke the

Dealer.deal() function.  

i guess i wanted it to work without returning values, but i think i might be faced with the functions having to.  if this spurs any thought, let me know.

~b
0
 
LVL 27

Expert Comment

by:Dabas
ID: 13631520
bramsquad:
Sounds OK, but what do you want Dealer.deal to do?
It has to cause the player or players to get cards, does it not?


Dabas
0
 
LVL 8

Author Comment

by:bramsquad
ID: 13721755
dabas,

thanks for your help, and yes, the Deal() function shuffles the deck and gives the players cards...i ended up just doing this

tbl.Dealer.Deal(tbl.Deck, tbl.Players())

so the function passes the players and the deck to the function, and the function manipulates it.  once again thanks for your help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question