Created
November 25, 2013 02:48
-
-
Save vanmichael/7635496 to your computer and use it in GitHub Desktop.
Add your name to the Game of Thrones List!
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
require 'pry' | |
class House | |
attr_reader :character, :house, :selection | |
def initialize | |
@characters = { | |
"Tyrion Lannister" => "House Lannister", | |
"Jon Snow" => "Night's Watch", | |
"Hodor" => "House Stark", | |
"Stannis Baratheon" => "House Baratheon", | |
"Theon Greyjoy" => "House Greyjoy" | |
} | |
end | |
def display_menu | |
puts "Enter 1 to print character list!" | |
puts "Enter 2 to add a character to the list!" | |
end | |
def get_menu_selection | |
@selection = gets.chomp | |
end | |
def get_character_info | |
puts "Enter a character's name!" | |
@character = gets.chomp | |
puts "Enter the character's house!" | |
@house = gets.chomp | |
end | |
def add_character | |
get_character_info | |
@characters[@character] = @house | |
end | |
def print_character_house | |
@characters.each do |key,value| | |
puts "#{key} represents the #{value}" | |
end | |
end | |
end |
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
#Game of Thrones | |
require './game_of_thrones.rb' | |
member = House.new | |
#Prompt a menu | |
member.display_menu | |
#get menu selection | |
member.get_menu_selection | |
if member.selection == '1' | |
#Print the Character and his House | |
member.print_character_house | |
elsif member.selection == '2' | |
#Add a character to the list | |
member.add_character | |
member.print_character_house | |
else | |
puts "Invalid Entry" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment