-
Notifications
You must be signed in to change notification settings - Fork 147
/
wave-1-game.rb
54 lines (41 loc) · 988 Bytes
/
wave-1-game.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
53
54
require_relative 'lib/scrabble'
module Scrabble
class Game
def initialize
@words = []
end
def play
start
while continue?
print_score(get_word)
end
conclude
end
private
def start
puts "Welcome to our Scrabble game!"
end
def continue?
return true if @words.length == 0 # haven't started playing yet
puts "Would you like to score another word? (Y/N)"
continue = gets.chomp
(continue == "Y") ? true : false
end
def get_word
puts "Enter a word to score:"
word = gets.chomp
@words << word
return word
end
def print_score(word)
result = Scrabble::Scoring.score(word)
puts "The score of #{ word } is #{ result }"
end
def conclude
highest_word = Scrabble::Scoring.highest_score_from_array(@words)
puts "The final highest scoring word is #{ highest_word }"
end
end
end
game = Scrabble::Game.new
game.play