Esempio n. 1
0
 def test_current_card(self):
     card_1 = Card("What is the capital of Alaska?", "Juneau", "Geography")
     card_2 = Card(
         "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?",
         "Mars", "STEM")
     card_3 = Card(
         "Describe in words the exact direction that is 697.5° clockwise from due north?",
         "North north west", "STEM")
     cards = [card_1, card_2, card_3]
     deck = Deck(cards)
     round = Round(deck)
     self.assertEqual(round.current_card(), card_1)
 def setUp(self):
     self.card_1 = Card("Geography", "What is the capital of Alaska?",
                        "Juneau")
     self.card_2 = Card(
         "STEM",
         "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?",
         "Mars")
     self.card_3 = Card(
         "STEM",
         "Describe in words the exact direction that is 697.5° clockwise from due north?",
         "North north west")
     self.deck = Deck([self.card_1, self.card_2, self.card_3])
     self.round = Round(self.deck)
    def test_round(self):
        card_1 = Card("What is the capital of Alaska?", "Juneau", 'Geography')
        card_2 = Card("What is the square root of 169?", "13", 'STEM')
        card_3 = Card("What is the power house of the freaking cell?",
                      "Mitochondria", 'STEM')

        cards = [card_1, card_2, card_3]

        deck = Deck(cards)

        round = Round(deck)

        assert round.deck == deck

        assert round.turns == []

        assert round.current_card() == card_1

        new_turn = round.take_turn('Juneau')

        assert isinstance(new_turn, Turn)

        assert new_turn.correct() == True

        assert round.turns == [new_turn]

        assert round.number_correct() == 1

        assert round.current_card() == card_2

        newer_turn = round.take_turn('12')

        assert len(round.turns) == 2
        assert (round.total_turns()) == 2

        assert newer_turn.correct() == False

        assert newer_turn.feedback() == 'Incorrect.'

        assert round.number_correct() == 1

        assert round.number_correct_by_category('Geography') == 1
        assert round.number_correct_by_category('STEM') == 0

        assert round.percent_correct() == 50.0

        assert round.percent_correct_by_category('Geography') == 100.0
        assert round.percent_correct_by_category('STEM') == 0.0

        assert round.current_card() == card_3
Esempio n. 4
0
 def test_percent_correct(self):
     card_1 = Card("What is the capital of Alaska?", "Juneau", "Geography")
     card_2 = Card(
         "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?",
         "Mars", "STEM")
     card_3 = Card(
         "Describe in words the exact direction that is 697.5° clockwise from due north?",
         "North north west", "STEM")
     cards = [card_1, card_2, card_3]
     deck = Deck(cards)
     round = Round(deck)
     round.take_turn("Juneau")
     round.take_turn("Venus")
     round.take_turn("North north west")
     self.assertEqual(round.percent_correct_by_category("Geography"), 100.0)
     self.assertEqual(round.percent_correct_by_category("STEM"), 50.0)
Esempio n. 5
0
 def test_number_correct(self):
     card_1 = Card("What is the capital of Alaska?", "Juneau", "Geography")
     card_2 = Card(
         "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?",
         "Mars", "STEM")
     card_3 = Card(
         "Describe in words the exact direction that is 697.5° clockwise from due north?",
         "North north west", "STEM")
     cards = [card_1, card_2, card_3]
     deck = Deck(cards)
     round = Round(deck)
     round.take_turn("Juneau")
     round.take_turn("Topeka")
     self.assertEqual(round.number_correct, 1)
     self.assertEqual(len(round.turns), 2)
     self.assertEqual(round.turns[-1].feedback(), "Incorrect")
Esempio n. 6
0
 def __init__(self, deck):
     self.round = Round(deck)
     self.line_break = "-----------------------------------------------------------------"
     self.total_cards = len(self.round.deck.cards)
Esempio n. 7
0
from lib.card import Card
from lib.deck import Deck
from lib.round import Round
from lib.turn import Turn
from lib.card_generator import CardGenerator

generator = CardGenerator("cards.txt")
cards = generator.cards
categories = []

deck = Deck(cards)
round = Round(deck)

print(f"Welcome! You're playing with {deck.count} cards.")
print("-------------------------------------")

i = 1
for card in cards:
    if card.category not in categories:
        categories.append(card.category)

    print(f"This is card number {i} out of {deck.count()}")
    print(f"Question: {card.question}")
    guess = input("")
    turn = round.take_turn(guess)
    print(turn.feedback())
    i += 1

print("****** Game over! ******")
print(
    f"You had {round.number_correct} out of {deck.count()} for a total score of {round.percent_correct()}%."