// view.js const readline = require('readline'); class WalletView { constructor() { this.rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); } displayBalance(balance) { console.log(`\nJelenlegi egyenleg: ${balance.toFixed(2)} Ft`); } displayMenu() { console.log('\nKérem válasszon egy műveletet:'); console.log('1. Pénz hozzáadása'); console.log('2. Pénz levonása'); console.log('3. Kilépés'); } getChoice() { return new Promise(resolve => { this.rl.question('Válasszon: ', choice => { resolve(choice); }); }); } getAmount() { return new Promise(resolve => { const askAmount = () => { this.rl.question('Adja meg az összeget: ', amount => { const parsedAmount = parseFloat(amount); if (isNaN(parsedAmount) || parsedAmount <= 0) { console.log('Érvénytelen összeg, próbálja újra.'); askAmount(); } else { resolve(parsedAmount); } }); }; askAmount(); }); } close() { this.rl.close(); } } module.exports = WalletView;