2079 8

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

RelationshipTypeMultiplicityDescription
User -- RegistrationAssociation1 to 1Each user must register once
Registration -- ValidationDependency1 to 1Registration triggers validation
User -- VoteAssociation1 to *A user can cast one or more votes (one per election)
Vote -- CandidateAssociation* to 1Many votes belong to one candidate
Candidate -- ResultAssociation1 to *Each candidate has result entries

Key Design Points

  1. User registers through the Registration class and is validated before being marked eligible (isEligible = true).
  2. Validation class checks user credentials and eligibility before allowing voting.
  3. Vote class records each vote with timestamp, linking user and candidate.
  4. Candidate maintains a running voteCount updated on each vote.
  5. 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.