File tree Expand file tree Collapse file tree 14 files changed +189
-128
lines changed Expand file tree Collapse file tree 14 files changed +189
-128
lines changed Original file line number Diff line number Diff line change 1+ # Name of workflow
2+ name : Node CI
3+
4+ on :
5+ - push
6+ - pull_request
7+
8+ env :
9+ CI : true
10+
11+ jobs :
12+ build :
13+
14+
15+ runs-on : ubuntu-latest
16+
17+ strategy :
18+
19+ matrix :
20+ node-version : [14.x]
21+
22+ steps :
23+
24+ - uses : actions/checkout@v2
25+
26+ - name : Use Node.js ${{ matrix.node-version }}
27+
28+ uses : actions/setup-node@v2
29+
30+ with :
31+ node-version : ${{ matrix.node-version }}
32+ cache : ' npm'
33+ - run : make install
34+ - run : make lint
35+ - run : make test
36+ - name : Test & publish code coverage
37+
38+ uses : paambaati/codeclimate-action@v3
39+
40+ env :
41+ CC_TEST_REPORTER_ID : ${{ secrets.CC_TEST_REPORTER_ID }}
42+ with :
43+ coverageCommand : make test-coverage
44+ debug : true
Original file line number Diff line number Diff line change 11### Hexlet tests and linter status:
22[ ![ Actions Status] ( https://github.com/KateChe31/frontend-project-44/actions/workflows/hexlet-check.yml/badge.svg )] ( https://github.com/KateChe31/frontend-project-44/actions )
33[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/4a5616b22f34629087fa/maintainability )] ( https://codeclimate.com/github/KateChe31/frontend-project-44/maintainability )
4+ [ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/4a5616b22f34629087fa/test_coverage )] ( https://codeclimate.com/github/KateChe31/frontend-project-44/test_coverage )
45## Демонстрация работы brain-even.js
56[ Смотреть запись в терминале] ( https://asciinema.org/connect/a69561bc-070b-40e4-9a31-cfc173f7f842 )
67## Демонстрация работы brain-calc.js
Original file line number Diff line number Diff line change 1- import playGame from '../src/index.js' ;
2-
3- const getRandomExpression = ( ) => {
4- const num1 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
5- const num2 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
6- const operations = [ '+' , '-' , '*' ] ;
7- const operation = operations [ Math . floor ( Math . random ( ) * operations . length ) ] ;
8- const expression = `${ num1 } ${ operation } ${ num2 } ` ;
9- let correctAnswer ;
10-
11- switch ( operation ) {
12- case '+' :
13- correctAnswer = num1 + num2 ;
14- break ;
15- case '-' :
16- correctAnswer = num1 - num2 ;
17- break ;
18- case '*' :
19- correctAnswer = num1 * num2 ;
20- break ;
21- }
22- return { question : expression , correctAnswer } ;
23- } ;
24-
25- const playGameCalc = ( ) => {
26- const gameQuestion = 'What is the result of the expression?' ;
27- playGame ( getRandomExpression , gameQuestion ) ;
28- } ;
1+ #!/usr/bin/env node
2+ import playGameCalc from '../src/games/brain-calc.js' ;
293
304playGameCalc ( ) ;
Original file line number Diff line number Diff line change 1- import playGame from '../src/index.js' ;
1+ #!/usr/bin/env node
2+ import playGameEven from '../src/games/brain-even.js' ;
23
3- const getRandomNumber = ( ) => Math . floor ( Math . random ( ) * 100 ) + 1 ;
4- const isEven = ( number ) => number % 2 === 0 ;
5-
6- const getQuestionAndAnswer = ( ) => {
7- const number = getRandomNumber ( ) ;
8- const question = number ;
9- const correctAnswer = isEven ( number ) ? 'yes' : 'no' ;
10- return { question, correctAnswer } ;
11- } ;
12-
13- const playGameEven = ( ) => {
14- const gameQuestion = 'Answer "yes" if the number is even, otherwise answer "no".' ;
15- playGame ( getQuestionAndAnswer , gameQuestion ) ;
16- } ;
17-
18- playGameEven ( ) ;
4+ playGameEven ( ) ;
Original file line number Diff line number Diff line change 1- #!/usr/bin/env node
2- import userName from "../src/cli.js" ;
1+ import greetings from "../src/cli.js" ;
2+
3+ greetings ( ) ;
Original file line number Diff line number Diff line change 1- import playGame from '../src/index.js' ;
2-
3- const calculateGCD = ( a , b ) => {
4- while ( b !== 0 ) {
5- const temp = b ;
6- b = a % b ;
7- a = temp ;
8- }
9- return a ;
10- } ;
11-
12- const getQuestionAndAnswer = ( ) => {
13- const num1 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
14- const num2 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
15- const question = `${ num1 } ${ num2 } ` ;
16- const correctAnswer = String ( calculateGCD ( num1 , num2 ) ) ;
17- return { question, correctAnswer } ;
18- } ;
19-
20- const playGameGCD = ( ) => {
21- const gameQuestion = 'Find the greatest common divisor of given numbers.' ;
22- playGame ( getQuestionAndAnswer , gameQuestion ) ;
23- } ;
1+ import playGameGCD from '../src/games/brain-gcd.js' ;
242
253playGameGCD ( ) ;
Original file line number Diff line number Diff line change 1- import playGame from '../src/index.js' ;
2-
3- const isPrime = ( number ) => {
4- if ( number < 2 ) {
5- return false ;
6- }
7- for ( let i = 2 ; i <= Math . sqrt ( number ) ; i += 1 ) {
8- if ( number % i === 0 ) {
9- return false ;
10- }
11- }
12- return true ;
13- } ;
14-
15- const getQuestionAndAnswer = ( ) => {
16- const number = Math . floor ( Math . random ( ) * 100 ) + 1 ;
17- const question = number ;
18- const correctAnswer = isPrime ( number ) ? 'yes' : 'no' ;
19- return { question, correctAnswer } ;
20- } ;
21-
22-
23- const playGamePrime = ( ) => {
24- const gameQuestion = 'Answer "yes" if given number is prime. Otherwise answer "no".' ;
25- playGame ( getQuestionAndAnswer , gameQuestion ) ;
26- } ;
1+ import playGamePrime from '../src/games/brain-prime.js' ;
272
283playGamePrime ( ) ;
Original file line number Diff line number Diff line change 1- import playGame from '../src/index.js' ;
2-
3- const generateProgression = ( start , step , length ) => {
4- const progression = [ ] ;
5- for ( let i = 0 ; i < length ; i += 1 ) {
6- progression . push ( start + step * i ) ;
7- }
8- return progression ;
9- } ;
10-
11- const getQuestionAndAnswer = ( ) => {
12- const progressionLength = Math . floor ( Math . random ( ) * 6 ) + 5 ;
13- const start = Math . floor ( Math . random ( ) * 50 ) + 1 ;
14- const step = Math . floor ( Math . random ( ) * 10 ) + 1 ;
15- const progression = generateProgression ( start , step , progressionLength ) ;
16-
17-
18- const hiddenIndex = Math . floor ( Math . random ( ) * progressionLength ) ;
19- const correctAnswer = String ( progression [ hiddenIndex ] ) ;
20-
21-
22- progression [ hiddenIndex ] = '..' ;
23- const question = progression . join ( ' ' ) ;
24-
25- return { question, correctAnswer } ;
26- } ;
27-
28- const playGameProgression = ( ) => {
29- const gameQuestion = 'What number is missing in the progression?' ;
30- playGame ( getQuestionAndAnswer , gameQuestion ) ;
31- } ;
1+ import playGameProgression from '../src/games/brain-progression.js' ;
322
333playGameProgression ( ) ;
Original file line number Diff line number Diff line change 55 "description" : " [](https://github.com/KateChe31/frontend-project-44/actions)" ,
66 "main" : " index.js" ,
77 "bin" : {
8- "code" : " bin/brain-games.js" ,
98 "brain-games" : " bin/brain-games.js" ,
109 "brain-even" : " bin/brain-even.js" ,
1110 "brain-calc" : " bin/brain-calc.js" ,
Original file line number Diff line number Diff line change 1+ import playGame from '../index.js' ;
2+
3+ const getRandomExpression = ( ) => {
4+ const num1 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
5+ const num2 = Math . floor ( Math . random ( ) * 100 ) + 1 ;
6+ const operations = [ '+' , '-' , '*' ] ;
7+ const operation = operations [ Math . floor ( Math . random ( ) * operations . length ) ] ;
8+ const expression = `${ num1 } ${ operation } ${ num2 } ` ;
9+ let correctAnswer ;
10+
11+ switch ( operation ) {
12+ case '+' :
13+ correctAnswer = num1 + num2 ;
14+ break ;
15+ case '-' :
16+ correctAnswer = num1 - num2 ;
17+ break ;
18+ case '*' :
19+ correctAnswer = num1 * num2 ;
20+ break ;
21+ }
22+ return { question : expression , correctAnswer } ;
23+ } ;
24+
25+ const playGameCalc = ( ) => {
26+ const gameQuestion = 'What is the result of the expression?' ;
27+ playGame ( getRandomExpression , gameQuestion ) ;
28+ } ;
29+
30+ export default playGameCalc ;
You can’t perform that action at this time.
0 commit comments