class FakeBitcoinWallet { constructor() { this.address = "fake_btc_address_" + Math.random().toString(36).substring(2); this.balanceUSD = 50000; // saldo fake inicial this.btcPriceUSD = 50000; // preço fictício do BTC } depositUSD(amount) { if (amount <= 0) return "Valor inválido"; this.balanceUSD += amount; return `Depósito fake de $${amount} realizado. Saldo: $${this.balanceUSD}`; } sendUSD(amount, destinationAddress) { if (amount > this.balanceUSD) return "Saldo insuficiente (fake)"; this.balanceUSD -= amount; return `Transferência fake de $${amount} para ${destinationAddress} concluída.`; } getBalanceBTC() { return (this.balanceUSD / this.btcPriceUSD).toFixed(8); } } // Uso const wallet = new FakeBitcoinWallet(); console.log("Endereço:", wallet.address); console.log("Saldo USD:", wallet.balanceUSD); console.log("Saldo BTC:", wallet.getBalanceBTC()); console.log(wallet.depositUSD(1000)); console.log(wallet.sendUSD(500, "endereco_fake_destinoo")); .

Postagens mais visitadas deste blog