Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:29:26+00:00 2026-06-05T23:29:26+00:00

Let’s assume public abstract class Game { // Base } public class Poker :

  • 0

Let’s assume

public abstract class Game
{
    // Base
}

public class Poker : Game
{
    // Lobby Object
    // NUMBER OF PLAYERS ( Max )   ----------
}                                            '
                                             '
public class Lobby                           '
{                                            '
    // List<Tables>                          '
}                                            '
                                             '
public class Table                           '
{                                            '
    // List<Player>                <---------'
}

How to access NUMBER OF PLAYERS from Table Object without redundant passing ?


EDIT I
You misunderstood my question, I’m sorry.
I want to access the maximum number that can join this Table from its game type.
So if It’s a Poker table I want to get NUMBER OF PLAYERS which is equal 10


EDIT II
Different Game types: Hearts, Spades, Poker, Estimation, … etc
Max number of players are : 4, 4, 10, 4, etc respectively.


EDIT III
Again, misunderstood my question, I want to be able to do the following :

When player attempt to join a table, I compare target table current
players number with its game type max number of players, so I decide
if the player can or can’t join it !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:29:28+00:00Added an answer on June 5, 2026 at 11:29 pm

    I think that the following relationship needs to be modelled:

    public abstract class Game
    {
        // force all Game descendants to implement the property
        public abstract int MaxPlayers { get; } 
    }
    
    public class Poker : Game
    {
        // Lobby Object
        public List<Lobby> Lobbies { get; set; }
    
        // NUMBER OF PLAYERS ( Max )
        // the abstract prop needs to be overridden here
        public override int MaxPlayers 
        { 
           get { return 4; } 
        }
    }   
    
    public class Lobby
    {
        public List<Table> Tables { get; set; }
    }
    
    public class Table                           
    {                    
        public Game CurrentGame { get; set; }
        public List<Player> Players { get; set; }
    
        // force the Game instance to be provided as ctor param.
        public Table(Game gameToStart)
        {
            CurrentGame = gameToStart;
        }
    }
    

    Inject the Game being played when the Table is instanced:

    var pokerGame = new Poker();
    // more code here, etc etc
    
    var myTable = new Table(pokerGame);
    

    To get the max number of players allowed in a Table instance:

    var maxAllowed = Table.CurrentGame.MaxPlayers;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have the following: abstract class A; class B : public A;
Let's assume we have the following class : public class ImageButton extends MovieClip {
Let's say I have the following classes : public class MyProductCode { private String
Let's imagine I have a Java class of the type: public class MyClass {
Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy=order)
Let's say I need to provide a method with a java.lang.Class object that represents
Let's say I have a class like this : public class MyClass { public
Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.