Beispiel #1
0
 /// <summary>
 /// Set the State of a candidate.
 /// </summary>
 /// <param name="candidate">The candidate for which to set state.</param>
 /// <param name="state">The state in which to initialize the candidate.</param>
 protected virtual void SetState(Candidate candidate, CandidateState.States state)
 {
     if (!candidateStates.ContainsKey(candidate))
     {
         candidateStates[candidate] = new CandidateState();
     }
     candidateStates[candidate].State = state;
 }
Beispiel #2
0
 /// <summary>
 /// Initialize candidate states.
 /// </summary>
 /// <param name="candidates">The candidates in this election.</param>
 /// <param name="state">The state in which to initialize the candidate.</param>
 protected void InitializeCandidateStates(IEnumerable <Candidate> candidates,
                                          CandidateState.States state = CandidateState.States.hopeful)
 {
     foreach (Candidate c in candidates)
     {
         SetState(c, state);
         candidateStates[c].VoteCount = 0;
     }
 }
Beispiel #3
0
        /// <inheritdoc/>
        protected override void SetState(Candidate candidate, CandidateState.States state)
        {
            if (!candidateStates.ContainsKey(candidate))
            {
                candidateStates[candidate] = new MeekCandidateState();
            }
            base.SetState(candidate, state);

            // Set KeepFactor to 0 for losers as per B.3
            if (new[] { CandidateState.States.defeated, CandidateState.States.withdrawn }
                .Contains(candidateStates[candidate].State))
            {
                (candidateStates[candidate] as MeekCandidateState).KeepFactor = 0.0m;
            }
        }