Skip to content

Instantly share code, notes, and snippets.

@vanmichael
Created November 25, 2013 02:48
Show Gist options
  • Save vanmichael/7635496 to your computer and use it in GitHub Desktop.
Save vanmichael/7635496 to your computer and use it in GitHub Desktop.
Add your name to the Game of Thrones List!
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
#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