Developed by: Yousuf
Language: Java (console-based application)
Implementation: Object-Oriented Programming using ArrayList
This project simulates a simple Electronic Voting Machine (EVM) in Java.
It uses important OOP concepts such as Encapsulation, Inheritance, Abstraction, Polymorphism and makes use of Java Collections (ArrayList) to dynamically store Candidates and Voters.
The goal is to allow pre-registered voters to cast votes to the registered candidates, store the votes in ArrayLists, and display the election results at the end.
| Concept | Explanation |
|---|---|
| Encapsulation | Private fields (voteCount, hasVoted) with public methods to access/mutate |
| Inheritance | Candidate and Voter inherit from base class Person |
| Polymorphism | displayDetails() method overridden in Candidate and Voter |
| Abstraction | VotingMachine (abstract) implemented by EVMSystem |
| Packages | common, candidate, voter, evm |
| ArrayList | Dynamic storage of all Candidate and Voter objects |
EVM_Project/ ├── common/ │ └── Person.java ├── candidate/ │ ├── Candidate.java │ └── CandidateManager.java ├── voter/ │ ├── Voter.java │ └── VoterManager.java ├── evm/ │ ├── VotingMachine.java │ └── EVMSystem.java └── Main.java
| Feature | Description |
|---|---|
| Candidate Registration | Add new candidates (name, ID, party) |
| Voter Registration | Add new voters (name, ID) |
| Voting | Voters cast vote using their ID and desired candidate ID |
| Validation | Only one vote per voter is allowed |
| Results Display | Shows vote counts and declares winner(s) |
| Dynamic Storage | Stores data in ArrayList, allowing unlimited growth at runtime |
Step 1 – Compile
javac -d . common/Person.java candidate/*.java voter/*.java evm/*.java Main.java
Step 2 – Run
java Main
---- Election Results ---- Ali Khan (Party A) - Votes: 3 Sara Ahmed (Party B) - Votes: 1Winner: Ali Khan (Party A) with 3 votes.
- This project uses ArrayList instead of normal arrays to store objects dynamically.
- It demonstrates how OOP + Java Collections can be used together in a real-world mini-project.
- Possible future improvements:
- Admin login
- File/database storage
- GUI using Swing or JavaFX