STAR++ v0.2.2
C++ implementation of STAR voting
Loading...
Searching...
No Matches
Star::Election Class Reference

The Election class represents a collection of candidates and ballots. More...

#include <star/election.h>

Classes

class  Ballot
 The Election::Ballot class represents a single ballot for a given election. More...
 
class  Builder
 The Election::Builder class is a utility through which elections can be prepared. More...
 
struct  Vote
 The Election::Voter struct represents a single vote for a candidate in an election. More...
 
struct  Voter
 The Election::Voter struct contains the details of a voter participating in an election. More...
 

Public Member Functions

 Election ()
 
const QList< Ballot > & ballots () const
 
QStringList candidates () const
 
bool isValid () const
 
QString name () const
 
const QList< Rank > & scoreRankings () const
 
int seatCount () const
 
int totalScore (const QString &candidate) const
 

Detailed Description

One of the two quintessential classes of STAR++, the Election class acts as a literal election. An Election is created via Election::Builder and then "counted" with a Calculator, which provides a corresponding ElectionResults instance.

See also
Calculator.

Constructor & Destructor Documentation

◆ Election()

Star::Election::Election ( )

Creates an invalid Election.

See also
Election::Builder.

Member Function Documentation

◆ ballots()

const QList< Election::Ballot > & Star::Election::ballots ( ) const

Returns the list of ballots provided for the election.

◆ candidates()

QStringList Star::Election::candidates ( ) const

Returns the list of candidates in the election.

◆ isValid()

bool Star::Election::isValid ( ) const

Returns true if the election is valid; otherwise, returns false.

In order for an election to be valid, it must:

  • Have two or more candidates
  • Have two or more ballots
  • Have a seat count of one or greater
  • Have a seat count that is less than or equal to its number of candidates

◆ name()

QString Star::Election::name ( ) const

Returns the name of the election.

◆ scoreRankings()

const QList< Rank > & Star::Election::scoreRankings ( ) const

Returns a list of all candidates in the election ranked by total score (descending).

◆ seatCount()

int Star::Election::seatCount ( ) const

Returns the number of seats prescribed for the election.

◆ totalScore()

int Star::Election::totalScore ( const QString &  candidate) const

Returns the total score for candidate candidate across all ballots.


The documentation for this class was generated from the following files: