|
1 | 1 | Races have Candidates!
|
2 | 2 | ======================
|
3 | 3 |
|
4 |
| -TODO: NEED BETTER TRANSTION HERE |
5 |
| -* need headline that transtions to basic |
6 |
| - race info |
7 |
| -* Then lead into candidate housekeeping |
| 4 | +With the basics of our `Candidate` class out of the way, let's |
| 5 | +move on to building out the `Race` class. This higher-level |
| 6 | +class will manage updates to our candidate instances, along with metadata |
| 7 | +about the race itself such as election date and office/district. |
8 | 8 |
|
9 |
| -Races have a date, office, and possibly a district if it's a |
10 |
| -congressional office. They also, of course, have candidates. In *elex3*, |
11 |
| -the *lib/parsery.py* code managed candiates, ensuring that county-level |
12 |
| -results were assigned to the appropriate candidate. |
| 9 | +Recall that in *elex3*, the *lib/parsery.py* ensured that county-level results were assigned to the appropriate candidate. |
| 10 | +We'll now migrate that logic over to the `Race` class, along with a few other repsonsibilities: |
13 | 11 |
|
14 |
| -We'll now migrate that logic over to the Race class, along with a few |
15 |
| -other repsonsibilities: |
16 |
| - |
17 |
| -- Keep track of individual candidates and update their vote counts |
18 |
| -- Determine which, candidate, any, won the race |
19 |
| -- Track overall vote count in the race |
| 12 | +- Tracking overall vote count for the race |
| 13 | +- Updating candidates with new county-level votes |
| 14 | +- Determining which candidate, if any, won the race |
20 | 15 |
|
21 | 16 | Total votes
|
22 | 17 | -----------
|
23 | 18 |
|
24 |
| -The Race class keep a running tally of all votes. This represnts |
25 |
| -the sum of all votes received by individual candidates. |
| 19 | +The *Race* class keeps a running tally of all votes. This figure is |
| 20 | +the sum of all county-level votes received by individual candidates. |
| 21 | + |
| 22 | +Let's build out the *Race* class with basic metadata fields and an *add\_result* method |
| 23 | +that updates the total vote count. |
26 | 24 |
|
27 |
| -Let's build out our initial *Race* class with an *add\_result* method |
28 |
| -that handles these updates. This should be pretty straightforward, and |
29 |
| -you'll notice that the tests mirror those used to perform the vote |
30 |
| -tallies on *Candidate* instances. |
| 25 | +This should be pretty straight-forward, and you'll notice that the tests mirror those used to |
| 26 | +perform vote tallies on *Candidate* instances. |
31 | 27 |
|
32 | 28 | .. code:: python
|
33 | 29 |
|
|
0 commit comments