Skip to main content

Practice · 3 of 4

State mutation

CHALLENGE
Difficulty: beginner+25 XP

Add two mutators to Account: void deposit(int amount) (increase balance) and void withdraw(int amount) (decrease it, but never below 0 — a withdraw attempt that overdraws leaves the balance unchanged). Both return nothing.

Back to lesson: Practice: Class workshop