-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
65 lines (59 loc) · 1.83 KB
/
index.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env node
import inquirer from "inquirer";
import chalkAnimation from "chalk-animation";
const questions = [
{
name: "accountId",
message: "Enter your Account id: ",
type: "input",
},
{
name: "accountPin",
type: "password",
message: "Enter your account pin",
},
{
name: "operations",
type: "list",
message: "What do u wanna do?",
choices: ["Check Balance", "Cash Withdrawal", "Cash Deposit", "Exit"],
},
];
const answers = await inquirer.prompt(questions.slice(0, 2));
const bankOperations = await inquirer.prompt(questions.slice(2, 3));
async function main() {
let balance = 100000;
if (bankOperations.operations === "Check Balance") {
chalkAnimation.neon(`Your Balance is: ${balance}$`);
} else if (bankOperations.operations === "Cash Withdrawal") {
const withDraw = await inquirer.prompt({
type: "input",
name: "amount",
message: "Enter the amount to withdraw: ",
validate: (input) => {
input > balance && chalkAnimation.neon(`Insufficient balance`);
return true;
},
});
let amount = withDraw.amount;
Number(amount);
balance -= amount;
chalkAnimation.neon(
`You withdrew ${amount}$, your current balance is ${balance}$`
);
} else if (bankOperations.operations === "Cash Deposit") {
const deposit = await inquirer.prompt({
type: "input",
name: "amount",
message: "Enter the amount to deposit: ",
});
let amount = deposit.amount;
balance += Number(amount);
chalkAnimation.neon(
`You successfully deposited ${amount}$, your current balance is ${balance}$`
);
} else if (bankOperations.operations === "Exit") {
chalkAnimation.neon(`Thank you for using our ATM have a nice day`);
}
}
main();