Question: For this assignment you are going to make a Piggy Bank class. The class must have the following functions: Default Constructor Parameter Constructor ( starting

For this assignment you are going to make a Piggy Bank class. The class must have the following functions:
Default Constructor
Parameter Constructor (starting amount of money)
Cannot have a negative balance of $x.xx
Deconstructor
If it is not broken, print out how much it had
Piggy bank had $x.xx upon deconstruction.
Deleted Copy Constructor
printSavings()
Prints out how much money is in the bank
"Piggy bank has $x.xx"
If it is smashed, print out "A smashed piggy bank can't hold any money"
deposit
Add money to the piggy bank
You cannot deposit negative values
Error: "Cannot deposit negative"
You cannot deposit into a smashed piggy bank
Error: "Cannot deposit money into broken bank"
withdraw
Remove money to the piggy bank
You cannot withdraw negative values
Error: "Cannot withdraw negative"
You cannot withdraw from a smashed piggy bank
Error: "Cannot withdraw money into broken bank"
You cannot withdraw more money than is in the piggy bank
Error: "Cannot withdraw more money than is available"
smash
Smashes the piggy bank
If there is money in the bank
"NOOO!!! You lost $x.xx"
A couple of notes:
- You will be given several main.pp files, they are the test cases. Do not commit them as .cpp.
- When submitting, don't commit the main.cpp files, as you will get link errors. Be careful what commit into the repo
-there was something missing from the assignment description. If you call printSavings on a smashed piggy bank, it should print out "A smashed piggy bank can't hold any money".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!