Write an Account class whose constructors all delegate to one validating constructor (owner must not be empty, opening balance at least the minimum), and show valid and invalid accounts.
Asha / savings / 1000
Ravi / savings / 2500
Meera / current / 8000
error: owner required
error: current needs at least 5000
All validation lives in one constructor; the shorter ones only supply defaults. Throwing from a constructor means no invalid Account object ever exists.
More Constructors and Destructors practice questions
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!
We use Google Analytics cookies to see how LearnFrenzy is used and make it better, and Google AdSense to keep it free.
No analytics or ad cookies are set until you accept. Privacy Policy
·
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!