Beginner
Hide the Balance
Wallet lets any code change balance directly. Make it private so only the wallet's own methods can touch it.
Also finish withdraw(n): it takes the money and returns true if the balance is enough, otherwise it changes nothing and returns false. The program should print true false 70.
What Check tests
- Your code has no type errors
- The console prints
true false 70 - Reading
balancefrom outside is rejected - Writing
balancefrom outside is rejected - The public methods still work
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.