Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Donte Handy Week 4: IC #8

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

dontehandy
Copy link

This project was relatively easy to understand after completing the battleship project. Once I slowed down my thinking and followed the initial interaction pattern, I was able to relate it to real-world elections, which felt very timely. I believe that familiarizing myself with real-world processes before coding them into a computer helps with understanding.


This pull request includes significant changes to the Election Tracker project, adding new classes, methods, and tests to support election tracking functionality. The most important changes include the addition of the Candidate, Race, and Election classes, along with their respective methods and tests.

New Class Implementations:

  • lib/candidate.rb: Added a Candidate class with attributes name, party, and votes, and a method vote_for to increment votes. This class follows the single-responsibility principle.

  • lib/race.rb: Added a Race class with attributes office and candidates, methods to register candidates, check if the race is open, close the race, determine the winner, and check for ties. This class follows the single-responsibility principle.

  • lib/election.rb: Added an Election class with attributes year and races, methods to add races, list candidates, count votes, and determine the winners of each race. This class follows the single-responsibility principle.

Documentation Updates:

  • README.md: Updated to include detailed interaction patterns for the Candidate, Race, and Election classes, demonstrating how to use the new methods and classes. [1] [2] [3]

Test Implementations:

  • spec/candidate_spec.rb: Added tests for the Candidate class to verify its attributes and the vote_for method.

  • spec/race_spec.rb: Added tests for the Race class to verify candidate registration, race status, determining the winner, and checking for ties.

  • spec/election_spec.rb: Added tests for the Election class to verify race addition, candidate listing, vote counting, and determining race winners.

  • spec/spec_helper.rb: Updated to require necessary files and configure RSpec.

…and adhere to the single-responsibility principle
@memcmahon
Copy link
Contributor

Great reflection on how you are better able to tackle code when you take some time to think about the 'real world' application of these concepts. Its always good to know more about how we work best :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants