-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshufflingDeck.js
32 lines (21 loc) · 907 Bytes
/
shufflingDeck.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
let Shuffling = require('./lib/shuffling');
/* ------------------------ reading command line arguments --------------------------------- */
let args = process.argv;
if(args.length != 3){
console.log("Program takes one integer argument!");
return;
}
if(isNaN(process.argv[2])){
console.log("Program takes one positive integer argument!");
return;
}
let numberOfCards = parseFloat(process.argv[2]);
if(numberOfCards === undefined || !Number.isInteger(numberOfCards) || numberOfCards <= 0){
console.log("Program takes one positive integer argument!");
return;
}
/* ------------------------ shuffling cards --------------------------------- */
let shaffleCards = new Shuffling(); // Initialization of Shuffling object
shaffleCards.initDecks(numberOfCards); // Initialization of decks
shaffleCards.start(); // start shuffling
console.log(shaffleCards.rounds);