Last active
February 20, 2019 19:32
-
-
Save cmjaimet/067b8b8359006214d5701202cf705657 to your computer and use it in GitHub Desktop.
Minimal ruby class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hangman | |
attr_reader :answer # creates getter method so class property is not accessed directly as data | |
def initialize() | |
@answer = get_answer # set the value of the class property | |
end | |
def get_answer() | |
puts "Enter Answer:" # prints a prompt to the screen | |
gets.chomp.upcase # gets the input from user and converts it to uppercase - convert later to a method to validate format (/[a-zA-Z ]{3,30}/) | |
end | |
end | |
puts Hangman.new.answer # create an object instance of the Hangman class and print the return value from the answer method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment