-
Notifications
You must be signed in to change notification settings - Fork 0
/
CupCake.cpp
48 lines (42 loc) · 1.34 KB
/
CupCake.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 CupCake. Constructor for CupCake 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 "CupCake.h"
CupCake::CupCake(string flavor, string frosting, string colorSprinkles) : Cake(flavor, frosting) {
ostringstream ostream;
price = CUPCAKEPRICE;
this->colorSprinkles = colorSprinkles;
if(frosting == "cream-cheese") {
price = CUPCAKEPRICE + .20;
}
ostream << flavor << " cupcake with " << frosting << " frosting and " << colorSprinkles;
ostream << " sprinkles " << BakedGood::ToString(); //CALL TO BASE CLASS
description = ostream.str();
}
string CupCake::ToString() const {
return description;
}
double CupCake::DiscountedPrice(int numGoods) {
double discountedPrice;
const int NUMFORLARGE = 4;
const int NUMFORSMALL = 2;
const double LARGEDISCOUNT = .40;
const double SMALLDISCOUNT = .30;
if(numGoods >= NUMFORLARGE) {
discountedPrice = numGoods * (price - LARGEDISCOUNT);
}
else if(numGoods >= NUMFORSMALL) {
discountedPrice = numGoods * (price - SMALLDISCOUNT);
}
else {
discountedPrice = numGoods * price;
}
return discountedPrice;
}