T
Tony Johansson
Hello!
I'm in the progress of creating a Black Jack game. I have created these
classes.
Game, Deck, Card, Player and Hand. A Game contains a Deck and a Deck
contains an array of Cards.
A Game also contains a List<Player> and a player contains a hand which is a
List of Cards.
None of these Game,Deck,Card,Player and Hand is instansiated in The MainGUI.
There is a second class called GameManager that is instansiating the Game
and this GameManager is instansiated in the MainGUI
The mainGUI contains a DataGridView and some buttons and some user controls
where each user control represent each player that will participate in this
Black jack game. We call this user control PlayerGUI.
The user control(PlayerGUI) that represent the player contains a TextBox for
the player name and some labels and two Buttons and a panel where each drawn
card should be displayed. The Card that is to be displayed in the panel of
the PlayerGUI is also a user control called CardGUI.
At the beginning of the game I create the PlayerGUI and place it in the form
and enter the name in the DataGridView cell where the column is called name
and when this cell go out of focus the TextBox in the PlayerGUI gets updated
with the same name.
I have a binding between the List<Player> and the DataGridView DataDource
and the List<Player> is placed in the Game class as I mentioned previously.
The MainGUI have four Buttons(NewPlayer, StartGame, CalculateWinner and
NewGame)
Now when I click on the StartGame I want to place some cards which
represented by the CardGUI in the Panel
of the PlayerGUI.
Now to my question which class should be responsible to deal the initial two
cards to each player where the croupier is also a player ?
It's only the MainGUI that know about the PlayerGUI so first I thought
MainGUI class would be a good choice
but I don't think that is good design.
The Game class would otherwise be a good choice but I don't have a reference
to the playerGUI where the CardGUI should be placed ?
So assume I choose to place the Deal method in the Game class how do I best
get access to all PlayerGUI that is placed in the MainGUI form class ?
//Tony
I'm in the progress of creating a Black Jack game. I have created these
classes.
Game, Deck, Card, Player and Hand. A Game contains a Deck and a Deck
contains an array of Cards.
A Game also contains a List<Player> and a player contains a hand which is a
List of Cards.
None of these Game,Deck,Card,Player and Hand is instansiated in The MainGUI.
There is a second class called GameManager that is instansiating the Game
and this GameManager is instansiated in the MainGUI
The mainGUI contains a DataGridView and some buttons and some user controls
where each user control represent each player that will participate in this
Black jack game. We call this user control PlayerGUI.
The user control(PlayerGUI) that represent the player contains a TextBox for
the player name and some labels and two Buttons and a panel where each drawn
card should be displayed. The Card that is to be displayed in the panel of
the PlayerGUI is also a user control called CardGUI.
At the beginning of the game I create the PlayerGUI and place it in the form
and enter the name in the DataGridView cell where the column is called name
and when this cell go out of focus the TextBox in the PlayerGUI gets updated
with the same name.
I have a binding between the List<Player> and the DataGridView DataDource
and the List<Player> is placed in the Game class as I mentioned previously.
The MainGUI have four Buttons(NewPlayer, StartGame, CalculateWinner and
NewGame)
Now when I click on the StartGame I want to place some cards which
represented by the CardGUI in the Panel
of the PlayerGUI.
Now to my question which class should be responsible to deal the initial two
cards to each player where the croupier is also a player ?
It's only the MainGUI that know about the PlayerGUI so first I thought
MainGUI class would be a good choice
but I don't think that is good design.
The Game class would otherwise be a good choice but I don't have a reference
to the playerGUI where the CardGUI should be placed ?
So assume I choose to place the Deal method in the Game class how do I best
get access to all PlayerGUI that is placed in the MainGUI form class ?
//Tony