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

  • SEARCH
  • Home
  • 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 6972613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:59:32+00:00 2026-05-27T16:59:32+00:00

Here is the code that shows what I try to accomplish. public partial class

  • 0

Here is the code that shows what I try to accomplish.

public partial class Form1 : Form
{
    public List<Player> Players { get; set; }

    public Form1()
    {
        InitializeComponent();

        Players = new List<Player>();
        Players.Add(new Player() { ID = "Hero", Stack = 1000 });
        Players.Add(new Player() { ID = "Villain", Stack = 500 });

        MessageBox.Show(Players[0].Chipleader.ToString());
    }
}

public class Player
{
    public string ID { get; set; }
    public int Stack { get; set; }
    public bool Chipleader
    {
        get
        {
            // Dependent on the stacks of the other players
            return Stack == Players.Max(S => S.Stack);
        }
    }
}

I want every Player object to have a property “Chipleader” indicating true if the that player has the biggest stack. The player object needs properties of the other players (list of players in base class) to be able to do this. The reason I need this property to be in the Player class is because I’m using ObjectListView to list my player objects in a listview. I hope someone can show me a simple/logical way to do this.

  • 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-05-27T16:59:32+00:00Added an answer on May 27, 2026 at 4:59 pm

    Typically, your “game” would manage which player is in the lead, not the other players. It’s typically a bad design to have a class require knowledge of other classes in order to function correctly.

    I would, instead, suggest having your “game” (the form) contain a Chipleader property that returned the player in the lead, ie:

    public Player Chipleader
    {
        get { return Players.OrderByDescending(s => s.Stack).FirstOrDefault(); }
    } 
    

    If you truly need this on Player, make a method, like so:

    public bool IsChipLeader(Form1 game)
    {
        // Maybe include check that "this" is part of the game...
        return this.Stack == game.Players.Max(s => s.Stack);
    }
    

    (I’d also recommend moving the Game logic into it’s own “Game” class, and encapsulate that in the form, instead of having the game logic in Form1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simple code that shows what I think is a bug when
Here is a minimal code that shows the problem: template<typename To, typename From> To
here's a runnable piece of code that shows what my problem is. I've got
I've got a program that worked until recently. The offending code is shown here:
Here is the code that cause me problem since few hours: TabItem newTab =
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Here is my code that fails: bool Table::win(const Card &card) { for (int i
I've got some code here that works great on IPv4 machines, but on our
There is a weird code here that I need to make work.. can you
We have some old C code here that's built with nmake. Is there an

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.