Question
Write a class called PiggyBank that contains the following private member variables: isBroken a bool indicating whether or not the piggy bank is broken savings
Write a class called PiggyBank that contains the following private member variables: isBroken a bool indicating whether or not the piggy bank is broken savings a double that holds the value stored in your piggy bank In addition, the class should contain the following public member functions: A default constructor This constructor should set isBroken to false and savings to 0.0. A parameterized constructor This constructor should one parameter, the initial savings value for your piggy bank, as well as initialize isBroken to false. A destructor The destructor should check if the piggy bank is broken and output the message if it is broken: Poor Broken Pig! getSavings This is an accessor function that should return you the amount stored in the savings variable depositMoney This function should accept a double and add that value to what is stored in the piggy's savings But.... You can't put money into a broken piggy bank. Negative money deposits are not allowed Return a bool showing if the money was deposited or not smash smash should change the broken bool so it indicates the piggy bank is broken, reduce the savings in the piggy bank to 0.0, and return the money in the piggy bank (before it was reduced to 0.0) Your class definition should be in a file called PiggyBank.h. The definition of the functions should be in a file called PiggyBank.cpp.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started