BIT302 ยท 2079 ยท 5 marks
Draw Class diagram for online voting system where user can vote the candidates. The system also generates the final result with respective vote counts as well. The user has to register and will be eligible only after proper validation.
Draw Class diagram for online voting system where user can vote the candidates. The system also generates the final result with respective vote counts as well. The user has to register and will be eligible only after proper validation. [5]
Software EngineeringChapter 3: System Modeling and DesignClass diagrams
Quick answer
The following class diagram represents an Online Voting System with registration, validation, voting, and result generation functionalities.
Class Diagram for Online Voting System
Description of Classes and Relationships
Class Diagram (UML Notation)
+------------------+ +----------------------+
| User | | Registration |
+------------------+ +----------------------+
| - userId: int |1 1 | - regId: int |
| - name: String |----------| - email: String |
| - email: String | | - password: String |
| - password: String| | - status: String |
| - isEligible: bool| +----------------------+
+------------------+ | + register(): void |
| + login(): bool | | + validate(): bool |
| + logout(): void | | + getStatus(): String|
| + viewResult():void| +----------------------+
+------------------+
|
| 1
|
| (after validation)
|
| *
+------------------+ +------------------+
| Vote | | Candidate |
+------------------+ +------------------+
| - voteId: int | * 1 | - candidateId:int|
| - userId: int |----------| - name: String |
| - candidateId:int| | - party: String |
| - voteTime:DateTime | - voteCount: int |
+------------------+ +------------------+
| + castVote():bool| | + getVoteCount() |
| + confirmVote() | | : int |
+------------------+ | + updateCount() |
| | : void |
| +------------------+
| |
| | 1
| |
| * | *
+------------------+ +------------------+
| Validation | | Result |
+------------------+ +------------------+
| - validationId | | - resultId: int |
| - userId: int | | - candidateId:int|
| - isVerified:bool| | - totalVotes: int|
+------------------+ | - rank: int |
| + checkEligibility| +------------------+
| (): bool | | + generateResult()|
| + verifyUser() | | : void |
| : bool | | + displayResult()|
+------------------+ | : void |
| + getWinner() |
| : Candidate |
+------------------+
Relationships Summary
| Relationship | Type | Multiplicity | Description |
|---|---|---|---|
| User -- Registration | Association | 1 to 1 | Each user must register once |
| Registration -- Validation | Dependency | 1 to 1 | Registration triggers validation |
| User -- Vote | Association | 1 to * | A user can cast one or more votes (one per election) |
| Vote -- Candidate | Association | * to 1 | Many votes belong to one candidate |
| Candidate -- Result | Association | 1 to * | Each candidate has result entries |
Key Design Points
- User registers through the Registration class and is validated before being marked eligible (
isEligible = true). - Validation class checks user credentials and eligibility before allowing voting.
- Vote class records each vote with timestamp, linking user and candidate.
- Candidate maintains a running
voteCountupdated on each vote. - Result class aggregates all votes and generates the final result with rankings and total vote counts.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.