-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mrsvolodya
committed
Sep 24, 2024
1 parent
b9eb4f1
commit b32106e
Showing
7 changed files
with
109 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
'use strict'; | ||
|
||
// Write your code here | ||
const readline = require('node:readline'); | ||
const terminal = readline.createInterface(process.stdin, process.stdout); | ||
const { getBullsAndCows } = require('./modules/getBullsAndCows'); | ||
const { checkIsValidUserInput } = require('./modules/checkIsValidUserInput'); | ||
|
||
async function runTerminal() { | ||
while (true) { | ||
const numbers = await new Promise((resolve) => { | ||
terminal.question( | ||
"Let's start game! Write four numbers in field:\n", | ||
resolve, | ||
); | ||
}); | ||
|
||
const check = await checkIsValidUserInput(numbers); | ||
|
||
if (!check) { | ||
process.stdout.write('False, check numbers, try again!\n'); | ||
|
||
continue; | ||
} | ||
|
||
const result = await getBullsAndCows(numbers); | ||
const resStr = JSON.stringify(result); | ||
|
||
process.stdout.write(`Result is ${resStr}\n`); | ||
|
||
const continueGame = await new Promise((resolve) => { | ||
terminal.question('Do you want to continue GAME, Yes/No ?', resolve); | ||
}); | ||
|
||
if (continueGame.toLowerCase() === 'no') { | ||
break; | ||
} | ||
} | ||
|
||
terminal.close(); | ||
} | ||
|
||
runTerminal(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters