Created
November 12, 2020 07:15
-
-
Save coke12103/a6d2a66b5034c51b41f51111d705aa2d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const readline = require('readline'); | |
class Yubaba{ | |
static keiyakusyo(){ | |
return new Promise((resolve, reject) => { | |
const rl = readline.createInterface({input: process.stdin, output: process.stdout}); | |
rl.question('契約書だよ。そこに名前を書きな。\n', (name) => { | |
console.log(`フン。${name}というのかい。贅沢な名だねぇ。`); | |
var name_arr = Array.from(name); | |
var new_name_index = Math.round(Math.random()*(name_arr.length -1)); | |
var new_name = name_arr[new_name_index]; | |
console.log(`今からお前の名前は${new_name}だ。いいかい、${new_name}だよ。分かったら返事をするんだ、${new_name}!!`); | |
rl.close(); | |
resolve(new_name); | |
}); | |
}) | |
} | |
} | |
async function main(){ | |
await Yubaba.keiyakusyo(); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment