|
budidharma wrote: Are you saying that classes defined inside the same namespace CAN access private members of other classes defined in the same namespace?
Nope. I'm saying that if you use the internal modifier instead of the private modified for class members, classes in the same assembly (I said namespace in my earlier post, but should have said assembly) will be able to access those internal members.
|
|
|
|
|
Ok, scared me for a second. I thought I was missing some fundamental understanding of C#. I just realized after reading through my code, that by simply writing three more public methods, I can transfer the dealer logic to the table logic - and the logic is better placed in the table anyways.
public BetAction[] GetPossibleActions(int Position); // Return an array of possible actions, given the game context, for the specified player.
public Update(BetAction Action, int Position); // Update the game context, given the player action at the specified position.
public int NextPlayerToAct(); // Return the position of the next player to act, given active players
By simply calling GetPossibleActions(NextPlayerToAct()), you'll recieve an array of possible actions. If it's empty - the hand's over and the simulator (or whatever is controlling input to the table) will simply call StartNextRound() (which may call FinalizeHand(), if your on the last hand).
If there are possible actions, (I have written public properties for the table which allow viewing, but not modifying table values), whatever selects the decision can view those properties and make a decision, then simply call the Update(SpecifiedAction, CurrentActingPlayer) which will update the game context and the player object.
... In other words, after thinking about this for awhile, I realized I don't need another class with private access.
Thanks!
|
|
|
|
|
I probably don't know enough about your application to advise you, but I won't let that stop me.
budidharma wrote: public BetAction[] GetPossibleActions(int Position); // Return an array of possible actions, given the game context, for the specified player.
Do you have a Player class? Would that be a good idea, do you think?
Also, who decides what the next BetAction will be? Maybe the logic for deciding should be in the Player class? If the logic varies, maybe have an IPlayer interface that can be implemented with various player strategy classes.
Here's what the code might look like:
public interface IPlayer
{
bool Bet();
event BetEventArgs BetPlaced;
}
Then somewhere else in your application:
PlayerCollection players = new PlayerCollection();
players.Add(new ConservativePlayer("Harry"));
players.Add(new AggressivePlayer("Joe"));
players.Add(new ModeratePlayer("Sue"));
foreach(Player p in players)
{
if(!p.Bet())
{
break;
}
}
The break looks ugly, and I'm sure there are cleaner ways of doing it. In part my suggestion is just guessing at a solution, but what I'm trying to get it is that maybe you should consider delegating some of the responsibilities of the table class to other classes. By putting everything in the table class, you may wind up with a monolithic class (a "God") class that does everything. This isn't considered good design in many circles.
Just a thought, and feel free to ignore it.
|
|
|
|
|
|
Not sure if this deserves a reply... Have you had a look at the list of controls on the "Toolbox" palette?
Matt Gerrans
|
|
|
|
|
Yeah, and?
Although, i usualy use sharp develop, but at the moment im using borlands c# builder, which i've noticed doesnt list some things. eg:
Process.Start - the Word 'Start' is not listed, which is pretty stupid, i'll go look around.
I may be back!!!
|
|
|
|
|
Okay, i dont find anything, well i found a link label, but where do i say what it actually links to?
|
|
|
|
|
You need to handle the LinkClicked event for the LinkLabel control:
private void linkWebSite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
System.Diagnostics.Process.Start("http://www.intelectix.com/");
}
catch
{
}
linkWebSite.LinkVisited = false;
} I hope this helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
> // Swallow the exception if anything goes wrong
Ack!
Please don't do this.
Matt Gerrans
|
|
|
|
|
Matt Gerrans wrote: Please don't do this.
I've seen that call fail and I'd rather just "ignore" the user click instead of displaying a message box telling the user that the browser could not be launched.
It's not that I do it often (to ignore exceptions).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hello,
Is it possible for the C# class to know as soon as its object(s) goes out of the function scope?
Otherwise the burden is a kind of left to client to explicitly notify the class for cleanup.
Is it possible to simulate this feature supported by traditional C++ with less effort in C#(supports class as referenced type)?
Thanks & Best Regards,
|
|
|
|
|
The quick answer is: no.
The long answer is: as a workaround, probably you should take a look at the IDisposable pattern and the "using" statement for automatic object disposal. After you look at it, you'll think: that guy is insane, this is not what I'm looking for! Yes, I know, but it's the nearest that you can get to RAII in C#.
I don't see dead pixels anymore...
Yes, even I am blogging now!
|
|
|
|
|
I can't find any documentation on this anywhere ... is it possible?
I have a class:
public Player
{
... private fields
... public methods
}
And there are many times I need to simply say this Player equals that Player and have all the values from one copied into the next. I have created a pubic method inside player, called "Copy()"
which simply creates a new player from the current players data and returns it.
So I can do something like:
player1 = player2.Copy()
But this is VERY annoying.
Can I simply overload the assignment operator so that I can do:
player1 = player2 and it will copy all the data from player 2 into player 1, rather than setting player1 equal to the reference of player2?
|
|
|
|
|
|
I am looking for a way to sort an ArrayList on Multiple fields similar to the following.
eg. select * from table1 order by col1 desc, col2 asc, col3 desc.
I have implemented the IComparer for the different fields. I am not sure how to go forward from here. I am trying to achieve best performance.
|
|
|
|
|
alam_pune wrote: I am looking for a way to sort an ArrayList on Multiple fields similar to the following.
eg. select * from table1 order by col1 desc, col2 asc, col3 desc.
I have implemented the IComparer for the different fields. I am not sure how to go forward from here. I am trying to achieve best performance.
Hmm, I think what you need to do is implement IComparer for each select statement. You'll need to implement an IComparer that sorts not just on one field but on all of them, or at least the ones in your select statement.
So to use your example, your IComparer would first compare the values in the first column between two items. If they aren't equal, you can stop the comparison and return the result. If they are equal, you move on to the next column and make a comparison there. Again, if they aren't equal, you can stop the comparisons and return the result. Else, you move on to the third column, and so on. The value of the result of each comparison will depend on the ordering you want, descending or ascending. I think this is what you're looking for. Hope this helps.
|
|
|
|
|
Exactly.
Thanks. I am such a dumb. Anyway thanks for your help.
|
|
|
|
|
Can anyone help me figure out how to make PropertyGrid show a property as a hyperlink? I have a solution that uses a cusom PropertyEditor, but I'd like to make it so that the user can just click on the property value, and link to the site.
Thanks,
Mark
|
|
|
|
|
Hi,
Are there any Gantt chart components on the market,
free or commercial ?
Thanks
|
|
|
|
|
|
Hello,
ComponentOne has a charting component that would meet your needs, Chart for .NET. Our Chart component allows you to create Gantt charts, and many others, both data bound and unbound. For more information on Chart for .NET or our many other controls, please visit http:\\www.componentone.com[^].
Suelinda W
Customer Engagement, ComponentOne LLC
|
|
|
|
|
Hi:
I have developed a analysis program for my users which runs for about 10 min and takes up the CPU 100% solid. The GUI also goes dead when the user hits the execute button to run the analysis and doesnt respond again until the analysis is done. I would like to give the user an option (with a button for instance) so that he can toggle the program execution on and off so that if the program is running and he wants to to get a responsive PC for a few moments to say launch Excel he can pause this analysis program and then resume execution. Is there a way to do this? How would the button work considering the GUI goes dead while the analysis is running?
Thanks, Sam
|
|
|
|
|
You'll need to look into multithreading. You'll want to run your analysis on a seperate thread so that the GUI thread doesn't freeze up. Then it's a simple matter to add a stop or pause (or both) button to you GUI and use that to halt your analysis.
|
|
|
|
|
sir please tell me how to implement data sending through socket program and also what are protocol supported by C#
iftikar
|
|
|
|
|
Search for socket programming on this website or on Google, there are plenty of examples available.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Morality Apart from God
Judah Himango
|
|
|
|