public void CalculateOneSidedOutcome() { CheckForZeroOptions(); _selectedVoteDistribution = new OneSidedVoteDistribution(); _selectedVoteDistribution.DistributeVotes(this); }
private void DetermineVoteDistributionStrategy() { if (_options.Any(option => option.PreferredNumberOfVotes > 0)) { _selectedVoteDistribution = new FixedVoteDistribution(); } else { _selectedVoteDistribution = new RandomVoteDistribution(); } }
public Survey CalculateOutcome(IVoteDistribution strategy) { if (!_options.Any()) { throw new SurveyDomainException("Cannot calculate a survey with no options"); } strategy.DistributeVotes(this); return(this); }
} // Necessary for Entity Framework Core public Survey(User owner, NonEmptyString topic, int numberOfRespondents, NonEmptyString respondentType) { if (numberOfRespondents < 1) { throw new SurveyDomainException("Survey should have at least one respondent"); } Owner = owner ?? throw new ArgumentNullException(nameof(owner)); Topic = topic ?? throw new ArgumentNullException(nameof(topic)); RespondentType = respondentType ?? throw new ArgumentNullException(nameof(respondentType)); NumberOfRespondents = numberOfRespondents; _selectedVoteDistribution = new RandomVoteDistribution(); AddSurveyCreatedEvent(); }