diff --git a/lib/card.rb b/lib/card.rb index e69de29bb..c67c1812b 100644 --- a/lib/card.rb +++ b/lib/card.rb @@ -0,0 +1,12 @@ +class Card + attr_reader :question, :answer, :category + + def initialize(question, answer, category) + @question = question + @answer = answer + @category = category + end + +end + + diff --git a/lib/turn.rb b/lib/turn.rb new file mode 100644 index 000000000..5365b7a62 --- /dev/null +++ b/lib/turn.rb @@ -0,0 +1,22 @@ +class Turn + attr_reader :guess, :card, :correct, :feedback + + def initialize(guess, card ) + @guess = guess + @card = card + @correct = correct + @feedback = [] + end + + def correct? + @guess = @card.answer + end + + def feedback + if @guess = card.answer + puts "Correct!" + else + puts "Incorrect!" + end + end +end \ No newline at end of file diff --git a/spec/card_spec.rb b/spec/card_spec.rb index 84a45a7a6..9760fe384 100644 --- a/spec/card_spec.rb +++ b/spec/card_spec.rb @@ -1,4 +1,5 @@ require './lib/card' +require 'pry' RSpec.describe Card do it 'exists' do @@ -6,7 +7,7 @@ expect(card).to be_instance_of(Card) end - + it 'has a question' do card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) @@ -25,3 +26,4 @@ expect(card.category).to eq(:Geography) end end + diff --git a/spec/turn_spec.rb b/spec/turn_spec.rb new file mode 100644 index 000000000..fc975fe69 --- /dev/null +++ b/spec/turn_spec.rb @@ -0,0 +1,31 @@ +require './lib/card' +require './lib/turn' +require 'pry' + +RSpec.describe Turn do + it "exists" do + card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + turn = Turn.new("Juneau", card) + + expect(turn).to be_instance_of(Turn) + end + it "returns correct" do + card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + turn = Turn.new("Juneau", card) + + expect(turn.correct?).to be true + end + + + + +end + + +# turn.card + +# turn.guess + +# turn.correct? + +# turn.feedback