Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago