-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerCake.cpp
48 lines (40 loc) · 1.26 KB
/
LayerCake.cpp
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
40
41
42
43
44
45
46
47
48
/*
Alexis Reeves, Section 10, [email protected]
Description: Definitions of class LayerCake. Constructor for LayerCake instances and Functions "ToString" and "DiscountedPrice".
Done without pair programming and in Visual Studio.
Late Days: none
*/
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#include "LayerCake.h"
LayerCake::LayerCake(string flavor, string frosting, int numLayers) : Cake(flavor, frosting) {
ostringstream ostream;
this->numLayers = numLayers;
price = LAYERCAKEPRICE;
if(frosting == "cream-cheese") {
price = LAYERCAKEPRICE + (1.00 * numLayers);
}
if(numLayers > 1) {
price = price + (3.00 * (numLayers - 1));
}
ostream << numLayers << "-layer " << flavor << " cake with " << frosting;
ostream << "frosting " << BakedGood::ToString(); //CALL TO BASE CLASS
description = ostream.str();
}
string LayerCake::ToString() const {
return description;
}
double LayerCake::DiscountedPrice(int numGoods) {
double discountedPrice;
const int DISCOUNTNUM = 3;
const double DISCOUNTPRICE = 2.00;
if(numGoods >= DISCOUNTNUM) {
discountedPrice = numGoods * (price - DISCOUNTPRICE);
}
else {
discountedPrice = numGoods * price;
}
return discountedPrice;
}