Skip to content

Commit 7c6f159

Browse files
committed
change names of constants and some parameters, imports updated
1 parent 4c23b4c commit 7c6f159

File tree

7 files changed

+22
-36
lines changed

7 files changed

+22
-36
lines changed

brain_games/constants.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
GREETING = [
2-
'Welcome to the Brain Games!\n'
3-
'May I have your name? '
4-
]
5-
EVEN_GAME_INTRODUCTION = [
6-
'Answer "yes" if the number is even, otherwise answer "no".'
7-
]
8-
CALC_GAME_INTRODUCTION = [
9-
'What is the result of the expression?'
10-
]
11-
GCD_GAME_INTRODUCTION = [
12-
'Find the greatest common divisor of given numbers.'
13-
]
14-
PROG_GAME_INTRODUCTION = [
15-
'What number is missing in the progression?'
16-
]
17-
PRIME_GAME_INTRODUCTION = [
18-
'Answer "yes" if given number is prime. Otherwise answer "no".'
19-
]
1+
GREETING = 'Welcome to the Brain Games!\n''May I have your name?'
2+
EVEN_GAME_BRIEFING = 'Answer "yes" if the number is even, otherwise answer "no".'
3+
CALC_GAME_BRIEFING = 'What is the result of the expression?'
4+
GCD_GAME_BRIEFING = 'Find the greatest common divisor of given numbers.'
5+
PROG_GAME_BRIEFING = 'What number is missing in the progression?'
6+
PRIME_GAME_BRIEFING = 'Answer "yes" if given number is prime. Otherwise answer "no".'
207

21-
GAMES_TO_WIN = 3
8+
NUMBER_OF_GAMES = 3
229
MATH_SYMBOLS = ['+', '-', '*']
23-
STEP_OF_SEQUENCE = [2, 3, 4, 5]

brain_games/game_engine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import brain_games.constants as const
33

44

5-
def game_engine(get_question_and_answer, introduction):
6-
username = prompt.string(''.join(const.GREETING))
5+
def game_engine(get_question_and_answer, briefing):
6+
username = prompt.string(const.GREETING)
77
print(f'Hello, {username}!')
8-
print(''.join(introduction))
9-
for _ in range(const.GAMES_TO_WIN):
8+
print(briefing)
9+
for _ in range(const.NUMBER_OF_GAMES):
1010
question, answer = get_question_and_answer()
1111
print(f'Question: {question}')
1212
user_answer = prompt.string('Your answer: ')

brain_games/games/calc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import random
22
from brain_games.game_engine import game_engine
33
from brain_games.constants import MATH_SYMBOLS
4-
from brain_games.constants import CALC_GAME_INTRODUCTION
4+
from brain_games.constants import CALC_GAME_BRIEFING
55

66

77
def get_expression_and_answer():
@@ -13,4 +13,4 @@ def get_expression_and_answer():
1313

1414

1515
def calc_game():
16-
game_engine(get_expression_and_answer, CALC_GAME_INTRODUCTION)
16+
game_engine(get_expression_and_answer, CALC_GAME_BRIEFING)

brain_games/games/even.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import random
22
from brain_games.game_engine import game_engine
3-
from brain_games.constants import EVEN_GAME_INTRODUCTION
3+
from brain_games.constants import EVEN_GAME_BRIEFING
44

55

66
def is_even(number):
@@ -16,4 +16,4 @@ def get_random_num_and_answer():
1616

1717

1818
def even_game():
19-
game_engine(get_random_num_and_answer, EVEN_GAME_INTRODUCTION)
19+
game_engine(get_random_num_and_answer, EVEN_GAME_BRIEFING)

brain_games/games/gcd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import random
22

33
from brain_games.game_engine import game_engine
4-
from brain_games.constants import GCD_GAME_INTRODUCTION
4+
from brain_games.constants import GCD_GAME_BRIEFING
55

66

77
def get_greatest_common_divisor(num1, num2):
@@ -18,4 +18,4 @@ def get_random_numbers_and_answer():
1818

1919

2020
def gcd_game():
21-
game_engine(get_random_numbers_and_answer, GCD_GAME_INTRODUCTION)
21+
game_engine(get_random_numbers_and_answer, GCD_GAME_BRIEFING)

brain_games/games/prime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import random
22

33
from brain_games.game_engine import game_engine
4-
from brain_games.constants import PRIME_GAME_INTRODUCTION
4+
from brain_games.constants import PRIME_GAME_BRIEFING
55

66

77
def is_prime(number):
@@ -19,4 +19,4 @@ def get_random_number_and_answer():
1919

2020

2121
def prime_game():
22-
game_engine(get_random_number_and_answer, PRIME_GAME_INTRODUCTION)
22+
game_engine(get_random_number_and_answer, PRIME_GAME_BRIEFING)

brain_games/games/progression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import random
22

33
from brain_games.game_engine import game_engine
4-
from brain_games.constants import STEP_OF_SEQUENCE
5-
from brain_games.constants import PROG_GAME_INTRODUCTION
4+
# from brain_games.constants import STEP_OF_SEQUENCE
5+
from brain_games.constants import PROG_GAME_BRIEFING
66

77

88
def get_random_sequence_and_answer():
@@ -20,4 +20,4 @@ def get_random_sequence_and_answer():
2020

2121

2222
def progression_game():
23-
game_engine(get_random_sequence_and_answer, PROG_GAME_INTRODUCTION)
23+
game_engine(get_random_sequence_and_answer, PROG_GAME_BRIEFING)

0 commit comments

Comments
 (0)