diff --git a/Wes-Game/controller.rb b/Wes-Game/controller.rb new file mode 100644 index 0000000..00638b9 --- /dev/null +++ b/Wes-Game/controller.rb @@ -0,0 +1,29 @@ +require_relative 'view' +require_relative 'model' + +class GameController + include GameView + + def run! + wineList = List.new + + loop do + Print::menu + case Print::fetch_user_input + when "V" + Print::print_list(wineList.wines) + when "A" + wineList.add_wine(Print::serialize_wine) + when "D" + wineList.delete_wine(Print::deleted_name) + when "Q" + puts "We're done" + exit + else + Print::error_message + end + end + end +end + +GameController.new.run! diff --git a/Wes-Game/model.rb b/Wes-Game/model.rb new file mode 100644 index 0000000..1b6e15f --- /dev/null +++ b/Wes-Game/model.rb @@ -0,0 +1,25 @@ +class Wine + attr_reader :name, :type, :comments, :rating + def initialize args + @name = args[:name] + @type = args[:type] + @comments = args[:comments] + @rating = args[:rating] + end +end + +class List + attr_reader :wines + def initialize + @wines = [] + end + + def add_wine(input) + @wines << Wine.new(input) + end + + def delete_wine(name) + @wines.delete_if { |n| n.name == name } + end + +end diff --git a/Wes-Game/view.rb b/Wes-Game/view.rb new file mode 100644 index 0000000..f899df7 --- /dev/null +++ b/Wes-Game/view.rb @@ -0,0 +1,63 @@ +module GameView + + module Print + + class << self + + def error_message + puts "That's not a command key. Try again!" + end + + def menu +menu = < " + gets.chomp + end + end + end +end