-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
40 lines (37 loc) · 1.24 KB
/
app.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
#!usr/bin/ruby
require ('./lib/anagram')
require ('./lib/helpers')
puts ""
puts "*******************************************************"
puts "* Anagrams, Antigrams, and Palindromes . . . Oh My!!! *"
puts "*******************************************************"
puts ""
play = 'y'
while play == 'y' do
puts ">>> Please enter a word, sentence, or text file name(ex. 'name.txt'):"
string1 = gets.chomp
while (not_word?(string1)) && !(string1.include?(".txt")) do
puts ">>> Error: '#{string1}' contains a non-word. Please enter another word or sentence:"
string1 = gets.chomp
end
base_string = Anagram.new(string1)
puts ""
puts ">>> Please enter a word, sentence, or text file name(ex. 'name.txt') to compare:"
string2 = gets.chomp
while (not_word?(string2)) && !(string2.include?(".txt")) do
puts ">>> Error: '#{string2}' contains a non-word. Please enter another word or sentence:"
string2 = gets.chomp
end
puts ""
puts ">>> #{base_string.anagram_check(string2)}"
puts ""
puts "******************************************"
puts "Would you like to enter another word (y/n)"
puts "******************************************"
play = gets.chomp.downcase
end
puts ""
puts "********"
puts "Goodbye!"
puts "********"
puts ""