-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
66 lines (57 loc) · 2.08 KB
/
Copy pathMain.py
File metadata and controls
66 lines (57 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# main.py
from Nominees import view_all_nominees, edit_nominee_name
from VoterRegistration import create_new_voter, view_all_voters, view_specific_voter
from VoteCasting import cast_vote
from VoteCounting import count_votes, view_results, primary_winner, preferential_winner
def main():
while True:
print("\n====== STUDENT UNION ELECTION SYSTEM ======")
print("1. Manage Nominees")
print("2. Voter Registration")
print("3. Cast Vote")
print("4. Counting")
print("5. Exit")
try:
choice = int(input("Enter your choice: "))
except ValueError:
print("❌ Please enter a number.")
continue
if choice == 1:
print("\n--- Nominees Menu ---")
print("1. View all nominees")
print("2. Edit nominee name")
sub = int(input("Enter choice: "))
if sub == 1:
view_all_nominees()
elif sub == 2:
edit_nominee_name()
elif choice == 2:
print("\n--- Voter Registration Menu ---")
print("1. Create voter")
print("2. View all voters")
print("3. Search voter")
sub = int(input("Enter choice: "))
if sub == 1:
create_new_voter()
elif sub == 2:
view_all_voters()
elif sub == 3:
view_specific_voter()
elif choice == 3:
cast_vote()
elif choice == 4:
results = count_votes()
view_results(results)
w_ballot, w_name = primary_winner(results)
if w_name:
print(f"🎉 Primary Winner: {w_name} (Ballot {w_ballot})")
else:
b, n = preferential_winner()
print(f"🎉 Preferential Winner: {n} (Ballot {b})")
elif choice == 5:
print("👋 Exiting...")
break
else:
print("❌ Enter a valid choice.")
if __name__ == "__main__":
main()