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 6106043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:02:14+00:00 2026-05-23T14:02:14+00:00

I am trying to make an application that lets users fill in a prediction

  • 0

I am trying to make an application that lets users fill in a prediction and score points based on their prediction and the actual outcome.

I have this method that is called GetPointsPrediction(). For now, the prediction has this form:

Dictionary<int, Driver> predictions = new Dictionary<int, Driver>
{
    {1, new Driver(10, "Michael Schumacher")},
    {2, new Driver(8, "Jensen Button")},
    {3, new Driver(7, "Felipe Massa")},
    {4, new Driver(9, "Fernando Alonso")}
};

The integers are the positions users think a driver will finish on. Now, I need to be able to calculate points based on the prediction and the results. To give points, I need three pieces of information in the results: position, driver, and points.

The drivers that have finished exactly at the position they were predicted receives full points. Drivers that have not finished at the predicted position but are in the top ten get reduced points.

All the sequential numbers you see are the positions.

Solution number 1:

Have a separate results set, and a dictionary with points for each position which will be used as a look up:

Dictionary<int, Driver> results = new Dictionary<int, Driver>
{
    {1, new Driver(10, "Michael Schumacher")},
    {2, new Driver(8, "Jensen Button")},
    {3, new Driver(9, "Fernando Alonso")}
};

Dictionary<int, int> points = new Dictionary<int, int>
{
    {1, 25},
    {2, 18},
    {3, 15},
    {4, 12},
    {5, 10}
};

Solution number 2:

Merging the points and the results.

Dictionary<int, Dictionary<int, Driver>> results = new Dictionary<int, Dictionary<int, Driver>>

Solution number 3:

Coming up with some kind of class that can hold everything:

public class DriverResult
{
    public Driver Driver { get; private set; }
    public int Points { get; private set; }
    public int StartPosition { get; private set; }
    public int FinishPosition { get; private set; }
}

And then

IEnumerable<DriverResult> raceResults = new List<DriverResult>

I like solution number 3, but I kind of feel that it isn’t coherent enough, and the name doesn’t feel good either. Solution 2 is probably to ugly to really be used, and solution 1 actually gives me a good way to separate the correctly predicted drivers with Intersect.

Maybe there’s some other solution I haven’t thought. What are the best practices concerning these design decisions?

The Driver class:

public class Driver : IEquatable<Driver>
    {
        public int DriverId { get; private set; }
        public string Name { get; private set; }

        public Driver(int driverId, string name)
        {
            DriverId = driverId;
            Name = name;
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as Driver);
        }

        public bool Equals(Driver other)
        {
            return other != null && other.DriverId == DriverId;
        }

        public override int GetHashCode()
        {
            return DriverId.GetHashCode();
        }
    }
  • 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-23T14:02:15+00:00Added an answer on May 23, 2026 at 2:02 pm

    Since predictions are sequential by position, they should be an array. Since points are also by position which is sequential, that should also be an array. There is no sense in using a Dictionary. However, if you want to look up your drivers by ID, you would need to make a Dictionary or SortedList of your drivers with ID being the key, not position which is sequential. So you’d have two arrays:

    Driver[] predictions = new Driver[]
    {
        new Driver(10, "Michael Schumacher"),
        new Driver(8, "Jensen Button")
        new Driver(7, "Felipe Massa")
        new Driver(9, "Fernando Alonso")
    };
    

    Index with position – 1, e.g. predictions[0] is prediction for position 1. Similarly, use an array for points:

    int[] points = new int[] { 25, 18, 15, 12, 10 };
    

    Access points by position – 1, e.g. points[0] is points for position 1.

    Instead of having a DriverResults, consider adding the other fields like DriverPoints and StartPosition to Driver. Then you can just update the Driver classes in the array.

    Edit: To store various race, test, season etc. results, create a class called DriverResults and have classes like RaceResults or SeasonResults inherit from it. Add a member to Driver:

    List<DriverResults> Results { get; set; }
    

    Now you can create SeasonResults or RaceResults and add them to this list, storing as many results as you want.

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

Sidebar

Related Questions

Im trying to make a very simple application that lets my client create their
I have been trying to test my application to make sure that all the
I am trying to make an application that will have a set of screens
I'm trying to make an application that keeps an object model in sync with
Alright so here is the deal. I am trying to make a application that's
Recently I was trying to make a calendar application that will display the current
I'm currently trying to make a small application that performs different duties. Right now
I'm trying to make a little console application that is able to deal with
I am trying to make a service that spawns a desktop application, and then
I'm trying to make an application in cocos2d that can be used on multiple

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.