kappa_toto 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/kappa_toto.rb +109 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a004c7226c8b6fab065634be5b263a57a91af33c
|
4
|
+
data.tar.gz: 113e79a9e08e97d9fe083252558cf3512e84c25c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d3e7642db0295d1910a74951bd2b145d4b3255ecfec8e81fa7d771706d31042be919ba77d18a4d1b2d4d39304ac7d5f9485ae6a17b532b94835cf03d8004b4b
|
7
|
+
data.tar.gz: e6892efed2911062b5b65c2c446e56c1ff718eb28349e14d6be6fadd3441d6b3549bbed4f32a05aa7c3126c02dac30ced1140232cd1fe0a032373a2dcb710b85
|
data/lib/kappa_toto.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
#Feeling lucky ?
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
class Toto
|
5
|
+
attr_accessor :count, :lucky_numbers, :user_numbers
|
6
|
+
def initialize(lucky_numbers, user_numbers)
|
7
|
+
@lucky_numbers = []
|
8
|
+
@user_numbers = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def input
|
12
|
+
system('cls')
|
13
|
+
puts "Enter 6 numbers from 1 to 49.\nPress 'Enter' to continue.."
|
14
|
+
gets.chomp
|
15
|
+
|
16
|
+
system('cls')
|
17
|
+
print "Enter the first number: "
|
18
|
+
@user_numbers << gets.chomp.to_i
|
19
|
+
|
20
|
+
system('cls')
|
21
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
22
|
+
print "Enter the second number: "
|
23
|
+
@user_numbers << gets.chomp.to_i
|
24
|
+
|
25
|
+
system('cls')
|
26
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
27
|
+
print "Enter the third number: "
|
28
|
+
@user_numbers << gets.chomp.to_i
|
29
|
+
|
30
|
+
system('cls')
|
31
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
32
|
+
print "Enter the forth number: "
|
33
|
+
@user_numbers << gets.chomp.to_i
|
34
|
+
|
35
|
+
system('cls')
|
36
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
37
|
+
print "Enter the fifth number: "
|
38
|
+
@user_numbers << gets.chomp.to_i
|
39
|
+
|
40
|
+
system('cls')
|
41
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
42
|
+
print "Enter the sixth number: "
|
43
|
+
@user_numbers << gets.chomp.to_i
|
44
|
+
|
45
|
+
system('cls')
|
46
|
+
puts "Your numbers are #{@user_numbers.join(", ")}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def win_numbers
|
50
|
+
while @lucky_numbers.size < 6
|
51
|
+
a = rand(49) + 1
|
52
|
+
if @lucky_numbers.include?(a)
|
53
|
+
a = rand(49) + 1
|
54
|
+
else
|
55
|
+
@lucky_numbers << a
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def prize
|
61
|
+
@count = 0
|
62
|
+
@user_numbers.each do |a|
|
63
|
+
@lucky_numbers.each do |b|
|
64
|
+
if a == b
|
65
|
+
@count+=1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def result
|
73
|
+
sleep(1)
|
74
|
+
puts "And..."
|
75
|
+
sleep(1)
|
76
|
+
|
77
|
+
case @count
|
78
|
+
when 3
|
79
|
+
puts "Almost! Not really..only 3."
|
80
|
+
when 4
|
81
|
+
puts "Hmm, kinda close. You got 4 numbers."
|
82
|
+
when 5
|
83
|
+
puts "Heh, suffer in sorrow. 5 numbers !!"
|
84
|
+
when 6
|
85
|
+
puts "Welp. You could be a millionaire. Sux for you. You got them all 6 numbers =)."
|
86
|
+
else
|
87
|
+
puts "Man, so unlucky. You didn't get anything.."
|
88
|
+
end
|
89
|
+
|
90
|
+
puts
|
91
|
+
puts "The lucky numbers were #{@lucky_numbers.join(", ")}"
|
92
|
+
|
93
|
+
puts "Press 'Enter' to exit."
|
94
|
+
gets.chomp
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
public
|
99
|
+
def game
|
100
|
+
user_numbers = []
|
101
|
+
lucky_numbers = []
|
102
|
+
|
103
|
+
toto = Toto.new(lucky_numbers, user_numbers)
|
104
|
+
toto.input
|
105
|
+
toto.win_numbers
|
106
|
+
toto.prize
|
107
|
+
toto.result
|
108
|
+
end
|
109
|
+
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kappa_toto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Danail Stoianov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Kappa toto Kappa
|
14
|
+
email: danail.stoqnov@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/kappa_toto.rb
|
20
|
+
homepage: http://rubygems.org/gems/kappa_toto
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.14
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Kappa
|
44
|
+
test_files: []
|