-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpdate.rb
52 lines (51 loc) · 1.17 KB
/
Update.rb
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
require './voter.rb'
require './Create.rb'
def border
puts "#" * 80
end
def get
gets.chomp.strip.capitalize
end
def update
border
puts " Would you like to update a (V)oter or a (P)olitician?"
choice = get
until choice == "V" || choice == "P" do
puts " Would you like to update a (V)oter or a (P)olitician?"
choice = get
end
case choice
when "P"
list_pol
puts " Which politician would you like to update?"
politician = get
if Politician.all_politicians[politician].nil?
border
" Politician has not yet been added to the ballot"
else
puts "Are you sure you want to delete #{politician}? (Y/N)"
answer = get
if answer == "Y"
Politician.all_politicians.delete(politician)
border
create
else
update
end
end
when "V"
border
list_voter
if Voter.all_voters.empty?
puts "No voters currently in register"
elsif Voter.all_voters.key? voter
puts " Please select voter from above list."
voter = get
else
puts " What Voter would you like to update?"
voter = get
Voter.all_voters.delete voter
end
create_voter
end
end