-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoting.py
More file actions
40 lines (33 loc) · 836 Bytes
/
voting.py
File metadata and controls
40 lines (33 loc) · 836 Bytes
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
class Voting:
def __init__(self):
self.total_votes = 0
self.__to_repulic = 0
self.__to_democratic = 0
def democratic(self):
self.__to_democratic += 1
self.total_votes+=1
print("Vote casted to the Democratic party")
def republic(self):
self.total_votes+=1
self.__to_repulic += 1
print("Vote casted to the Republic Party")
def clear(self):
self.total_votes = 0
return "Machine cleared"
def __str__(self):
return f"total Votes casted: {self.total_votes}\nDemocratic: {self.__to_democratic}\nRepublic: {self.__to_repulic}"
Voting1 = Voting()
Voting1.clear()
print(Voting1)
Voting1.republic()
Voting1.democratic()
Voting1.republic()
Voting1.democratic()
Voting1.republic()
Voting1.democratic()
Voting1.republic()
Voting1.republic()
Voting1.republic()
Voting1.republic()
Voting1.democratic()
print(Voting1)