-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayerCake.cpp
More file actions
36 lines (31 loc) · 965 Bytes
/
LayerCake.cpp
File metadata and controls
36 lines (31 loc) · 965 Bytes
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
//
// Created by Jared Gray on 11/27/21.
//
#include "LayerCake.h"
#include <string>
LayerCake::LayerCake(string cakeFlavor, string frostingType = "none", int layerCount = 0) : Cake(cakeFlavor, frostingType) {
this->layerCount = layerCount;
}
string LayerCake::TotalCost() {
totalPrice = itemPrice;
if(layerCount > 1){
totalPrice += (layerPrice * (layerCount - 1));
}
if(frostingType == "cream-cheese"){
totalPrice += (frostingPrice * layerCount);
}
return to_string(totalPrice);
}
string LayerCake::ToString() {
string test = to_string(layerCount) + "-layer " + cakeFlavor + " cake with " + frostingType + " frosting ($" + TotalCost() + ")";
return test;
}
double LayerCake::DiscountedPrice(int itemQuantity){
if(itemQuantity >= 3){
discountCost = itemQuantity * totalPrice - (itemQuantity * 2);
}
else {
discountCost = itemQuantity * totalPrice;
}
return discountCost;
}