File tree Expand file tree Collapse file tree 11 files changed +25
-19
lines changed Expand file tree Collapse file tree 11 files changed +25
-19
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { calcGame } from '../games/calc-game.js'
2+ import { calcGame } from '../src/ games/calc-game.js'
33
44calcGame ( )
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { evenGame } from '../games/even-game.js'
2+ import { evenGame } from '../src/ games/even-game.js'
33
44evenGame ( )
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { nodGame } from '../games/NOD-game.js'
2+ import { nodGame } from '../src/ games/NOD-game.js'
33
44nodGame ( )
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { isPrimeGame } from '../games/prime-game.js'
2+ import { isPrimeGame } from '../src/ games/prime-game.js'
33
44isPrimeGame ( )
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { progressionGame } from '../games/progression-game.js'
2+ import { progressionGame } from '../src/ games/progression-game.js'
33
44progressionGame ( )
Original file line number Diff line number Diff line change 1- import { gamelogic } from '../src/ index.js'
1+ import { gamelogic } from '../index.js'
22import readlineSync from 'readline-sync'
3+ import { randomNum } from '../random-num.js'
34const rules = 'Find the greatest common divisor of given numbers.'
45
56function nod ( ) {
6- const number1 = Math . floor ( Math . random ( ) * ( 20 ) )
7- const number2 = Math . floor ( Math . random ( ) * ( 20 ) )
7+ const number1 = randomNum
8+ const number2 = randomNum
89 console . log ( `Question: ${ number1 } ${ number2 } ` )
910 const stranswer = readlineSync . question ( 'Your answer: ' )
1011 const answer = parseInt ( stranswer , 10 )
Original file line number Diff line number Diff line change 1- import { gamelogic } from '../src/ index.js'
1+ import { gamelogic } from '../index.js'
22import readlineSync from 'readline-sync'
3+ import { randomNum } from '../random-num.js'
34const rules = 'What is the result of the expression?'
45function calc ( ) {
56 const operators = [ '+' , '-' , '*' ]
67 const randomOperator = operators [ Math . floor ( Math . random ( ) * operators . length ) ]
7- const number1 = Math . floor ( Math . random ( ) * ( 9 ) )
8- const number2 = Math . floor ( Math . random ( ) * ( 10 ) )
8+ const number1 = randomNum
9+ const number2 = randomNum
910 console . log ( `Question: ${ number1 } ${ randomOperator } ${ number2 } ` )
1011 const stranswer = readlineSync . question ( 'Your answer: ' )
1112 const answer = parseInt ( stranswer , 10 )
Original file line number Diff line number Diff line change 1- import { gamelogic } from '../src/ index.js'
1+ import { gamelogic } from '../index.js'
22import readlineSync from 'readline-sync'
3+ import { randomNum } from '../random-num.js'
34const rules = 'Answer "yes" if the number is even, otherwise answer "no"'
45
56export function isEven ( ) {
6- const number = Math . floor ( Math . random ( ) * ( 52 ) )
7+ const number = randomNum
78 console . log ( `Question: ${ number } ` )
89 const answer = readlineSync . question ( 'Your answer: ' )
910 let result
Original file line number Diff line number Diff line change 1- import { gamelogic } from '../src/ index.js'
1+ import { gamelogic } from '../index.js'
22import readlineSync from 'readline-sync'
3+ import { randomNum } from '../random-num.js'
34const rules = 'Answer "yes" if given number is prime. Otherwise answer "no"'
45
56function isPrime ( number ) {
@@ -17,7 +18,7 @@ function isPrime(number) {
1718 return 'yes'
1819}
1920function primenumber ( ) {
20- const number = Math . floor ( Math . random ( ) * 100 )
21+ const number = randomNum
2122 console . log ( `Question: ${ number } ` )
2223 const answer = readlineSync . question ( 'Your answer: ' )
2324 let result = isPrime ( number )
Original file line number Diff line number Diff line change 1- import { gamelogic } from '../src/ index.js'
1+ import { gamelogic } from '../index.js'
22import readlineSync from 'readline-sync'
3+ import { randomNum } from '../random-num.js'
34const rules = ( 'What number is missing in the progression?' )
45
56function progressionElem ( ) {
6- const start = Math . floor ( Math . random ( ) * 10 )
7- const step = Math . floor ( Math . random ( ) * 15 )
7+ const start = randomNum
8+ const step = randomNum
89 let numbers = [ ]
910 for ( let i = 0 ; i <= ( Math . floor ( Math . random ( ) * 6 + 5 ) ) ; i ++ ) {
1011 let elem = ( start + i * step )
@@ -15,7 +16,7 @@ function progressionElem() {
1516
1617function progression ( seq ) {
1718 seq = progressionElem ( )
18- let index = Math . floor ( Math . random ( ) * seq . length )
19+ let index = randomNum * seq . length
1920 let result = seq [ index ]
2021 seq [ index ] = '..'
2122 console . log ( `Question: ${ seq . join ( ' ' ) } ` )
You can’t perform that action at this time.
0 commit comments