Skip to content

A console-based Java voting system demonstrating OOP concepts with dynamic storage using ArrayList. A ) Register Candidates & Voters B) Cast votes with validation C ) Display election results & winner D ) Fully console-based, easy to run Perfect mini-project to showcase Java OOP + Collections in action!

Notifications You must be signed in to change notification settings

Muhammad-Yousuf2641/EVM-Electronic-Voting-Machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗳️ Electronic Voting Machine (EVM) – Java OOP Project

Developed by: Yousuf
Language: Java (console-based application)
Implementation: Object-Oriented Programming using ArrayList

📌 Project Overview

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.

✅ Concepts Used

ConceptExplanation
EncapsulationPrivate fields (voteCount, hasVoted) with public methods to access/mutate
InheritanceCandidate and Voter inherit from base class Person
PolymorphismdisplayDetails() method overridden in Candidate and Voter
AbstractionVotingMachine (abstract) implemented by EVMSystem
Packagescommon, candidate, voter, evm
ArrayListDynamic storage of all Candidate and Voter objects

🧱 Folder Structure

EVM_Project/
├── common/
│   └── Person.java
├── candidate/
│   ├── Candidate.java
│   └── CandidateManager.java
├── voter/
│   ├── Voter.java
│   └── VoterManager.java
├── evm/
│   ├── VotingMachine.java
│   └── EVMSystem.java
└── Main.java

⚙️ Features

FeatureDescription
Candidate RegistrationAdd new candidates (name, ID, party)
Voter RegistrationAdd new voters (name, ID)
VotingVoters cast vote using their ID and desired candidate ID
ValidationOnly one vote per voter is allowed
Results DisplayShows vote counts and declares winner(s)
Dynamic StorageStores data in ArrayList, allowing unlimited growth at runtime

🧭 Program Flow

display

🧑‍💻 How to Run

Step 1 – Compile

javac -d . common/Person.java candidate/*.java voter/*.java evm/*.java Main.java

Step 2 – Run

java Main

🧭 REGISTER VOTER

REGISTER VOTER

🧭 CAST VOTE

CASTVOTE

✅ Example Output (Results Section)

---- Election Results ----
Ali Khan (Party A) - Votes: 3
Sara Ahmed (Party B) - Votes: 1

Winner: Ali Khan (Party A) with 3 votes.

📌 Notes

  • 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

About

A console-based Java voting system demonstrating OOP concepts with dynamic storage using ArrayList. A ) Register Candidates & Voters B) Cast votes with validation C ) Display election results & winner D ) Fully console-based, easy to run Perfect mini-project to showcase Java OOP + Collections in action!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages