Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

class help

Posted on 2005-03-24
4
Medium Priority
?
237 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
  • 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

Industry Leaders: 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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

572 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