From 35e7bf742e344b1018ebdcbd758c6c448f2753eb Mon Sep 17 00:00:00 2001 From: BrodyNics77 Date: Thu, 22 Aug 2024 13:37:56 -0500 Subject: [PATCH 01/19] fet: Added Card Class --- lib/card.rb | 10 ++++++++++ lib/runner.rb | 3 +++ lib/turn.rb | 7 +++++++ spec/card_spec.rb | 1 + spec/turn_spec.rb | 4 ++++ 5 files changed, 25 insertions(+) create mode 100644 lib/runner.rb create mode 100644 lib/turn.rb create mode 100644 spec/turn_spec.rb diff --git a/lib/card.rb b/lib/card.rb index e69de29bb..52bc52b56 100644 --- a/lib/card.rb +++ b/lib/card.rb @@ -0,0 +1,10 @@ +class Card + + attr_reader :question, :answer, :category + + def initialize(question, answer, category) + @answer = answer + @question = question + @category = category + end +end \ No newline at end of file diff --git a/lib/runner.rb b/lib/runner.rb new file mode 100644 index 000000000..b663e516c --- /dev/null +++ b/lib/runner.rb @@ -0,0 +1,3 @@ +require './lib/card' + +card = Card.new diff --git a/lib/turn.rb b/lib/turn.rb new file mode 100644 index 000000000..8e1b6c68d --- /dev/null +++ b/lib/turn.rb @@ -0,0 +1,7 @@ +class Turn + attr_reader + + def initialize() + + end +end \ No newline at end of file diff --git a/spec/card_spec.rb b/spec/card_spec.rb index 84a45a7a6..b91340574 100644 --- a/spec/card_spec.rb +++ b/spec/card_spec.rb @@ -24,4 +24,5 @@ expect(card.category).to eq(:Geography) end + require 'pry' ; binding.pry end diff --git a/spec/turn_spec.rb b/spec/turn_spec.rb new file mode 100644 index 000000000..f74001cab --- /dev/null +++ b/spec/turn_spec.rb @@ -0,0 +1,4 @@ +require './lib/turn' +require './lib/card' + +Respec.describe \ No newline at end of file From f6c03280e8b1db16685b101372d05e5a23a6a153 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 14:40:03 -0500 Subject: [PATCH 02/19] feat: Added Deck and Turn classes --- lib/Deck.rb | 0 spec/deck_spec.rb | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/Deck.rb create mode 100644 spec/deck_spec.rb diff --git a/lib/Deck.rb b/lib/Deck.rb new file mode 100644 index 000000000..e69de29bb diff --git a/spec/deck_spec.rb b/spec/deck_spec.rb new file mode 100644 index 000000000..e69de29bb From 329566da723a8de8d4867caef5454701521c01b4 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 14:45:09 -0500 Subject: [PATCH 03/19] Feat: Finished Deck and Turn classes --- lib/Deck.rb | 16 ++++++++++++++++ lib/turn.rb | 17 ++++++++++++++--- spec/card_spec.rb | 2 +- spec/deck_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ spec/turn_spec.rb | 32 +++++++++++++++++++++++++++++++- 5 files changed, 98 insertions(+), 5 deletions(-) diff --git a/lib/Deck.rb b/lib/Deck.rb index e69de29bb..354a1b163 100644 --- a/lib/Deck.rb +++ b/lib/Deck.rb @@ -0,0 +1,16 @@ +class Deck + attr_reader :card, :counts + + def initialize(card, count) + @count = count + @card = card + end + + def count + @card.count + end + + def cards_in_category(catagory) + @card.select {|card| card.caregory == catagory} + end +end \ No newline at end of file diff --git a/lib/turn.rb b/lib/turn.rb index 8e1b6c68d..f1270cd92 100644 --- a/lib/turn.rb +++ b/lib/turn.rb @@ -1,7 +1,18 @@ class Turn - attr_reader + attr_reader :card, :guess - def initialize() - + def initialize(card, guess) + @card = card + @guess = guess + end + + def correct? + @guess.downcase == @card.answer.downcase + else + false + end + + def feedback + @guess.correct == false end end \ No newline at end of file diff --git a/spec/card_spec.rb b/spec/card_spec.rb index b91340574..9fd88047a 100644 --- a/spec/card_spec.rb +++ b/spec/card_spec.rb @@ -24,5 +24,5 @@ expect(card.category).to eq(:Geography) end - require 'pry' ; binding.pry + # require 'pry' ; binding.pry end diff --git a/spec/deck_spec.rb b/spec/deck_spec.rb index e69de29bb..967825167 100644 --- a/spec/deck_spec.rb +++ b/spec/deck_spec.rb @@ -0,0 +1,36 @@ +require './lib/card' +require './lib/deck' + +Respec.describe Deck do + it 'exist' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new(cards) + + expect(deck.card).to eq ([card_1, card_2, card_3]) + end + + it 'counts cards' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new(cards) + + expect(deck.count).to eq(3) + end + + it 'has categorys' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + + expect(deck.cards_in_category(:STEM)).to eq([card_2, card_3]) + expect(deck.cards_in_category(:Geography)).to eq([card_1]) + expect(deck.cards_in_category(:Pop_Culture)).to eq([]) + expect(deck.cards_in_category(:STEM)).to be_a(Array) + expect(deck.cards_in_category(:Geography)).to be_a(Array) + expect(deck.cards_in_category(:Pop_Culture)).to be_a(Array) + end + diff --git a/spec/turn_spec.rb b/spec/turn_spec.rb index f74001cab..d39931f8a 100644 --- a/spec/turn_spec.rb +++ b/spec/turn_spec.rb @@ -1,4 +1,34 @@ require './lib/turn' require './lib/card' -Respec.describe \ No newline at end of file +Respec.describe Turn do + it 'describes turn class' do + turn = Turn.new("Saturn", card) + + expect(turn).to be_instance_of(Turn) + end + + it 'has an answer' do + turn = Turn.new("Saturn", card) + + expect(turn.answer).to eq("Mercury") + end + + it 'has a question' do + turn = Turn.new("Saturn", card) + + expect(turn.question).to eq("Which planest is closest to the sun?") + end + + it 'has a catagory' do + turn = Turn.new("Saturn", card) + + expect(turn.catagory).to eq(:STEM) + end + + it 'gives feedback' do + turn = Turn.new("Saturn", card) + + expect(@guess.correct).to be false + end +end \ No newline at end of file From 883f8fd540908a06a14845cc5dfee7ad378570d5 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 14:51:06 -0500 Subject: [PATCH 04/19] Test: test for initiazle and class --- spec/Round_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 spec/Round_spec.rb diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb new file mode 100644 index 000000000..1151ecd76 --- /dev/null +++ b/spec/Round_spec.rb @@ -0,0 +1,12 @@ +require './lib/card' +require './lib/turn' +require './lib/deck' +require './lib/round' + +Respec.describe Round do + it 'describes Round class' do + round = Round.new(deck) + + expect(round.deck). to eq(Round) + expect(round.turns).to eq([]) + end \ No newline at end of file From 7221fd941333c8f58cb73d571db89d9dd6348e30 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 15:43:21 -0500 Subject: [PATCH 05/19] Feat:Started Round class --- lib/round.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/round.rb diff --git a/lib/round.rb b/lib/round.rb new file mode 100644 index 000000000..e69de29bb From b5355bb4b3a864749775087fce9fb70fa2ab823b Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 15:46:11 -0500 Subject: [PATCH 06/19] Feat: Added turn class --- lib/round.rb | 11 +++++++++++ spec/Round_spec.rb | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/round.rb b/lib/round.rb index e69de29bb..34cbb8e6b 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -0,0 +1,11 @@ +class Round + attr_reader :guess, :turn + + def initialize(guess, turn) + @guess = guess + @turn = turn + end + + + +end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 1151ecd76..1f07c21d6 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -5,8 +5,23 @@ Respec.describe Round do it 'describes Round class' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) round = Round.new(deck) expect(round.deck). to eq(Round) expect(round.turns).to eq([]) - end \ No newline at end of file + expect(round.current_card).to eq(card_1) + end + + it 'starts a new round' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + + expect + +end \ No newline at end of file From 42bcf7d744760f92badb8a6ca41a7e7204ff161a Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 17:11:17 -0500 Subject: [PATCH 07/19] Feat:Added Methods for Class round --- lib/round.rb | 29 ++++++++++++++++++++++++----- spec/Round_spec.rb | 36 +++++++++++++++++++++++++++++++++++- spec/deck_spec.rb | 2 +- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/lib/round.rb b/lib/round.rb index 34cbb8e6b..1fb9fbf83 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -1,11 +1,30 @@ class Round - attr_reader :guess, :turn + attr_reader :deck, :turns, :current_card - def initialize(guess, turn) - @guess = guess - @turn = turn + def initialize(guess, turns) + @deck = deck + @turns = [] + @current_card = current_card end + def new_turn(@guess) + new_turn = Turn.new(guess, current_card) + @turns << new_turn + @current_card = deck.card[@turns.count] + end + + def current_card(card) + @card.current_card + end - + def take_turn(card) + take_turn + + def number_correct + if @turns.correct? + 1 + else + 0 + end + end end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 1f07c21d6..068b0a283 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -16,12 +16,46 @@ expect(round.current_card).to eq(card_1) end + it + it 'starts a new round' do card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + new_turn = Turn.new(guess, current_card) + + expect(round.new_turn). to eq([]) + end + + it 'number of correct scores' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.number_correct).to eq(1) + end + + it 'shows current card' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) - expect + expect(round.current_card). to eq(card_1) + end + + it 'takes turns' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + expect(round.take_turn("Venus")).to eq(turn) end \ No newline at end of file diff --git a/spec/deck_spec.rb b/spec/deck_spec.rb index 967825167..deba12453 100644 --- a/spec/deck_spec.rb +++ b/spec/deck_spec.rb @@ -33,4 +33,4 @@ expect(deck.cards_in_category(:Geography)).to be_a(Array) expect(deck.cards_in_category(:Pop_Culture)).to be_a(Array) end - +end From ab539385969cdaaa3ddc98a58dc968a3275bf695 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 17:13:19 -0500 Subject: [PATCH 08/19] Fix: Typo --- spec/Round_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 068b0a283..ec96b9abc 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -40,7 +40,7 @@ expect(round.number_correct).to eq(1) end - it 'shows current card' do + it 'shows current cards at play' do card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) @@ -58,4 +58,5 @@ round = Round.new(deck) expect(round.take_turn("Venus")).to eq(turn) + end end \ No newline at end of file From 6d011773fbb654d209ac8add1b09319968680ce3 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 17:16:59 -0500 Subject: [PATCH 09/19] Test: Added Test for turn count --- lib/round.rb | 3 ++- spec/Round_spec.rb | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/round.rb b/lib/round.rb index 1fb9fbf83..a5ff6936d 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -18,7 +18,8 @@ def current_card(card) end def take_turn(card) - take_turn + take_turn == @current_card + end def number_correct if @turns.correct? diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index ec96b9abc..38599249d 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -40,7 +40,7 @@ expect(round.number_correct).to eq(1) end - it 'shows current cards at play' do + it 'shows correct cards at play' do card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) @@ -59,4 +59,13 @@ expect(round.take_turn("Venus")).to eq(turn) end + + it 'current counts at play' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.turns.count).to eq(2) end \ No newline at end of file From 23dd8fbd6f3ee077825215f54393323e2891dd83 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 17:22:22 -0500 Subject: [PATCH 10/19] Test: Added Test for displaying feedback --- lib/round.rb | 6 ++++++ spec/Round_spec.rb | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/round.rb b/lib/round.rb index a5ff6936d..4b34fb440 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -28,4 +28,10 @@ def number_correct 0 end end + + def turns_count + @turns.count == 2 + end + + end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 38599249d..d51e964d5 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -68,4 +68,15 @@ round = Round.new(deck) expect(round.turns.count).to eq(2) + end + + it 'displays last turn feedback' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.turns.last.feedback).to eq("Incorrect") + end end \ No newline at end of file From b5cc5499bc4091e14afa9d0a99be04a92e49d2b8 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:07:55 -0500 Subject: [PATCH 11/19] Test: Added test for catagorys correct in --- lib/round.rb | 9 +++++++-- spec/Round_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/round.rb b/lib/round.rb index 4b34fb440..bfb9d809f 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -7,7 +7,7 @@ def initialize(guess, turns) @current_card = current_card end - def new_turn(@guess) + def new_turn(guess) new_turn = Turn.new(guess, current_card) @turns << new_turn @current_card = deck.card[@turns.count] @@ -33,5 +33,10 @@ def turns_count @turns.count == 2 end - + def turns_last_feedback(turns) + last_turn = turns.last + last_turn.feedback + end + + def end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index d51e964d5..217274c80 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -79,4 +79,14 @@ expect(round.turns.last.feedback).to eq("Incorrect") end + + it 'shows catagorys correct in' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.number_correct_by_category(:Geography)). to eq(1) + end end \ No newline at end of file From e8f5bfb644dc9edcc52f79b02633975b1b464542 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:10:23 -0500 Subject: [PATCH 12/19] Feat: Added catagorys correct in --- lib/round.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/round.rb b/lib/round.rb index bfb9d809f..f207b798b 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -38,5 +38,10 @@ def turns_last_feedback(turns) last_turn.feedback end - def + def number_of_catagorys_correct_in(deck) + last_catagory = catagory.correct + last_catagory.feedback + end + + end \ No newline at end of file From 072cb75cc72f4cbb2fe0822260642d61da2c31e1 Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:14:03 -0500 Subject: [PATCH 13/19] Feat: Addded Test and Feature for catagorys correct in --- lib/round.rb | 9 ++++++--- spec/Round_spec.rb | 12 +++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/round.rb b/lib/round.rb index f207b798b..daf91f8b5 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -39,9 +39,12 @@ def turns_last_feedback(turns) end def number_of_catagorys_correct_in(deck) - last_catagory = catagory.correct - last_catagory.feedback + geography_catagory = catagory.correct + geography_catagory.feedback end - + def number_of_catagorys_correct_in(deck) + stem_catagory = catagory.correct + stem_catagory.feedback + end end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 217274c80..752476beb 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -80,7 +80,7 @@ expect(round.turns.last.feedback).to eq("Incorrect") end - it 'shows catagorys correct in' do + it 'shows catagorys correct in (:Geography)' do card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) @@ -89,4 +89,14 @@ expect(round.number_correct_by_category(:Geography)). to eq(1) end + + it 'shows catagorys correct in (:STEM)' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.number_correct_by_category(:STEM)).to eq(0) + end end \ No newline at end of file From fa484c75fcd2c01762700cbc53ac2da72505e93b Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:34:08 -0500 Subject: [PATCH 14/19] Feat: Added test and methods for perecent calculation --- lib/round.rb | 16 ++++++++++++++++ spec/Round_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/round.rb b/lib/round.rb index daf91f8b5..8c352a2e0 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -47,4 +47,20 @@ def number_of_catagorys_correct_in(deck) stem_catagory = catagory.correct stem_catagory.feedback end + + def percent_correct(deck) + deck = @deck.size + @deck.count do |deck| + end + percent = (deck.correct / deck) + perecent.round(2) + end + + def perecent_correct_by_category(deck) + deck = @deck.size + catagory_correct = @deck.count do |game| + end + percent = (catagory_correct / catagory) + percent.round(2) + end end \ No newline at end of file diff --git a/spec/Round_spec.rb b/spec/Round_spec.rb index 752476beb..b11400762 100644 --- a/spec/Round_spec.rb +++ b/spec/Round_spec.rb @@ -99,4 +99,24 @@ expect(round.number_correct_by_category(:STEM)).to eq(0) end + + it 'calculates percent of correct' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.percent_correct).to eq(50.0) + end + + it 'calculates percent by category' do + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) + card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) + deck = Deck.new([card_1, card_2, card_3]) + round = Round.new(deck) + + expect(round.percent_correct_by_category(:Geography)).to eq(100.0) + end end \ No newline at end of file From 5835472242e855a5dc7217ff246cc003362d783e Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:37:11 -0500 Subject: [PATCH 15/19] Feat: Added objects to runner.rb --- lib/runner.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/runner.rb b/lib/runner.rb index b663e516c..31e6deb48 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -1,3 +1,10 @@ -require './lib/card' +require './lib/card.rb' +require './lib/deck.rb' +require './lib/round.rb' +require './lib/turn.rb' -card = Card.new +card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) +card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) +card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) +deck = Deck.new([card_1, card_2, card_3]) +round = Round.new(deck) From f31460ba28fd054a5c01510661e755fe8c093daa Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:46:32 -0500 Subject: [PATCH 16/19] Feat: Added text prompt for runner.rb --- lib/runner.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/runner.rb b/lib/runner.rb index 31e6deb48..fc8dec44f 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -3,8 +3,16 @@ require './lib/round.rb' require './lib/turn.rb' +puts "Welcome to Brody's flashcard game!" +puts "--------------------------------------" +puts "press P to start or Q to quit!" + +get + card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) card_3 = Card.new("Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", :STEM) deck = Deck.new([card_1, card_2, card_3]) round = Round.new(deck) + +game.play \ No newline at end of file From 7b3445a79f27a981b2c13373daf9e14f05f20c5f Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:54:46 -0500 Subject: [PATCH 17/19] Fix: turn class feedback method fixed --- lib/runner.rb | 2 +- lib/turn.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runner.rb b/lib/runner.rb index fc8dec44f..f13c6993e 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -7,7 +7,7 @@ puts "--------------------------------------" puts "press P to start or Q to quit!" -get +input = gets.chomp.upcase card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM) diff --git a/lib/turn.rb b/lib/turn.rb index f1270cd92..dfb8874f7 100644 --- a/lib/turn.rb +++ b/lib/turn.rb @@ -12,7 +12,7 @@ def correct? false end - def feedback + def feedback(guess) @guess.correct == false end end \ No newline at end of file From 0dfbae998c258d389dc08d585399ed0f74766e1e Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:58:07 -0500 Subject: [PATCH 18/19] Fix: spacing between classes and attr_readers --- lib/Deck.rb | 1 + lib/round.rb | 1 + lib/runner.rb | 6 ++++++ lib/turn.rb | 1 + 4 files changed, 9 insertions(+) diff --git a/lib/Deck.rb b/lib/Deck.rb index 354a1b163..790adf9c9 100644 --- a/lib/Deck.rb +++ b/lib/Deck.rb @@ -1,4 +1,5 @@ class Deck + attr_reader :card, :counts def initialize(card, count) diff --git a/lib/round.rb b/lib/round.rb index 8c352a2e0..b7e828729 100644 --- a/lib/round.rb +++ b/lib/round.rb @@ -1,4 +1,5 @@ class Round + attr_reader :deck, :turns, :current_card def initialize(guess, turns) diff --git a/lib/runner.rb b/lib/runner.rb index f13c6993e..fb0890981 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -7,6 +7,12 @@ puts "--------------------------------------" puts "press P to start or Q to quit!" +def play + deck.cards.each do |card| + puts "Question #{card.question}" + + + input = gets.chomp.upcase card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography) diff --git a/lib/turn.rb b/lib/turn.rb index dfb8874f7..db3d3faee 100644 --- a/lib/turn.rb +++ b/lib/turn.rb @@ -1,4 +1,5 @@ class Turn + attr_reader :card, :guess def initialize(card, guess) From 4ebb30db4ba4a5252af3ed75bb57d4578b4af49c Mon Sep 17 00:00:00 2001 From: Brody Nikolaos Date: Tue, 27 Aug 2024 18:58:48 -0500 Subject: [PATCH 19/19] Fix: Removed pry statment --- spec/card_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/card_spec.rb b/spec/card_spec.rb index 9fd88047a..84a45a7a6 100644 --- a/spec/card_spec.rb +++ b/spec/card_spec.rb @@ -24,5 +24,4 @@ expect(card.category).to eq(:Geography) end - # require 'pry' ; binding.pry end