Skip to content

Commit

Permalink
menu program and makefile adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaswebdev committed Mar 21, 2019
1 parent 86cde73 commit 65311d6
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 24 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
t=
play-ruby:
@echo "Qual aposta quer fazer. Ex: t='megasena' ou t='quina'"
ruby ruby/lib/run_$(t).rb
ruby ruby/lib/run.rb
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ _Lottery in many languages_


### Run the program em Ruby Lang:
#### Megasena
```
make play-ruby ARG="megasena"
make play-ruby
```
#### Quina
```
make play-ruby ARG="quina"
```


### Let the game begin!
7 changes: 2 additions & 5 deletions ruby/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
play-megasena:
ruby lib/run_megasena.rb

play-quina:
ruby lib/run_quina.rb
play:
ruby lib/run.rb
7 changes: 1 addition & 6 deletions ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ rspec
```

### Run the program:
#### Megasena
```
make play-megasena
```
#### Quina
```
make play-quina
make play-ruby
```
33 changes: 33 additions & 0 deletions ruby/lib/run.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
def menu
puts "Quer jogar o que Rogerinho? \n
[1] Mega-sena [2] Quina [3] Lotomania [0] Exit \n\n"
print 'Digite aqui a sua escolha: '
end

menu

game_chosen = gets.chomp

while game_chosen != '0'
system('clear')

case game_chosen
when '1'
puts "\nMEGA-SENA"
load 'ruby/lib/run_megasena.rb'

when '2'
puts "\nQUINA"
load 'ruby/lib/run_quina.rb'

when '3'
puts "\nLOTOFACIL"
load 'ruby/lib/run_lotofacil.rb'

else
"\nNenhuma escolha possível para: #{game_chosen}"
end

menu
game_chosen = gets.chomp
end
11 changes: 10 additions & 1 deletion ruby/lib/run_lotofacil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

print 'How many games you wanna play? '

char = gets.delete("\n")
char = gets.chomp
numb = char.to_i

if char == '0'

puts 'Please, enter a number bigger than "0".'

elsif %w[buceta xoxota priquito ppk].include?(char.downcase)

puts 'Sorry, "' + char + '" is not a number, but is a excelent choice! :p'

elsif numb > 0

game = Lotofacil.new
game.show(numb)

else

puts 'Sorry, but "' + char + '" is not a number.'

end

10 changes: 9 additions & 1 deletion ruby/lib/run_megasena.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

print 'How many games you wanna play? '

char = gets.delete("\n")
char = gets.chomp
numb = char.to_i

if char == '0'

puts 'Please, enter a number bigger than "0".'

elsif %w[buceta xoxota priquito].include?(char.downcase)

puts 'Sorry, "' + char + '" is not a number, but is a excelent choice! :p'

elsif numb > 0

game = MegaSena.new
game.show(numb)

else

puts 'Sorry, but "' + char + '" is not a number.'

end
10 changes: 9 additions & 1 deletion ruby/lib/run_quina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

print 'How many games you wanna play? '

char = gets.delete("\n")
char = gets.chomp
numb = char.to_i

if char == '0'

puts 'Please, enter a number bigger than "0".'

elsif %w[buceta xoxota priquito ppk].include?(char.downcase)

puts 'Sorry, "' + char + '" is not a number, but is a excelent choice! :p'

elsif numb > 0

game = Quina.new
game.show(numb)

else

puts 'Sorry, but "' + char + '" is not a number.'

end

0 comments on commit 65311d6

Please sign in to comment.