I don't know how to do this. I can only talk about the general card games. First, since we want to use the oo design method, we must design it from top to bottom.
Let's first analyze the process of the lianzhong game. First, we enter the game hall, select a card table, and people can join the game. We can have a lot of games, until this table is full
Department staff left. In this way, the class can be constructed from top to bottom:
1. Hall class)
This class is not complex and can be defined in this way
Public class Hall
{
// Private member variable
// Hall attributes
Private String m_strName; // Hall name
Private String m_strDescription; // Hall description
Private String m_strServerIP; // The Host ip address in the hall and the ip address for Internet access. The specific protocol is required.
...... // Other required attributes
// Objects contained in the hall
Private ArrayList m_arrUsers; // User Group
Private ArrayList m_arrConnections; // corresponding to the connection of each user, which can be udp or tcp.
Pirvate ArrayList m_arrTables; // table class Array
Private ArrayList m_arrMatchs; // each game class corresponds to each game.
// Attributes
Public String Name ....
....
// The method is as follows:
// Construction
Public Hall ()
{
Start server winservice...
}
/// Create a socket connection for each user
/// The main function is to obtain the user's ip address, establish a socket, and then add the user to the online user group.
/// <Parameter> a_objUser, a User object, </parameter>
Public void Connect (User a_objUser)