-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCupCake.cpp
More file actions
39 lines (34 loc) · 1.03 KB
/
CupCake.cpp
File metadata and controls
39 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Created by Jared Gray on 11/27/21.
//
#include "CupCake.h"
#include <string>
CupCake::CupCake(string cakeFlavor, string frostingType = "none", string sprinkleColor = "none")
: Cake(cakeFlavor, frostingType) {
this->sprinkleColor = sprinkleColor;
}
string CupCake::TotalCost() {
if(frostingType == "cream-cheese"){
totalPrice = frostingPrice + itemPrice;
}
else{
totalPrice = itemPrice;
}
return to_string(totalPrice);
}
string CupCake::ToString() {
string test = cakeFlavor + " cupcake with " + frostingType + " frosting and " + sprinkleColor + " sprinkles ($" + TotalCost() + ")";
return test;
}
double CupCake::DiscountedPrice(int itemQuantity){
if(itemQuantity >= 2 && itemQuantity < 4){
discountPrice = itemQuantity * totalPrice - (itemQuantity * 0.30);
}
else if(itemQuantity >= 4){
discountPrice = itemQuantity * totalPrice - (itemQuantity * 0.40);
}
else{
discountPrice = itemQuantity * totalPrice;
}
return discountPrice;
}