A console-based Voting System built using Java and Object-Oriented Programming (OOP) principles. This project demonstrates real-world voting logic, including age validation, unique voter identification, duplicate vote prevention, and tie handling. Ideal for beginners, college mini-projects, and practicing Java OOP concepts.
- ✅ Age Validation: Only voters aged 18 and above can participate.
- 🆔 Unique Voter ID: Each voter must provide a unique identifier.
- 🚫 Duplicate Vote Prevention: Ensures no voter can cast multiple votes.
- 🗳️ Multi-Candidate Voting: Support for voting among multiple candidates.
- 📊 Vote Counting and Results: Displays final vote tallies and outcomes.
- ⚖️ Automatic Tie Detection: Handles scenarios where candidates tie for the lead.
- 🧩 Modular OOP Design: Clean, encapsulated classes for maintainability.
- Object-Oriented Programming (OOP)
- Classes and Objects
- Encapsulation
- Arrays and Collections (e.g., HashSet, ArrayList)
- Loops and Conditional Statements
- Scanner for User Input
VotingSystem.java # Main class to run the application
Election.java # Handles voting logic and validations
Candidate.java # Model class for candidates
Voter.java # Model class for voters
-
Clone the Repository:
git clone <repository-url> cd voting-system-java
-
Compile the Code:
javac *.java -
Run the Application:
java VotingSystem
- 🆔 Voter ID Validation: Ensures every voter provides a unique ID; duplicates are rejected automatically.
- 🚫 Duplicate Vote Prevention: Tracks voted IDs using a HashSet to allow only one vote per voter.
- ⚖️ Tie Handling: If candidates tie for the highest votes, the result is declared as a tie.
- Integrate file or database storage for voter and election data.
- Add an admin panel for candidate management.
- Develop a GUI version using Swing or JavaFX.
- Transform into a REST API with Spring Boot.