-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBread.cpp
36 lines (32 loc) · 962 Bytes
/
Bread.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
/*
Alexis Reeves, Section 10, [email protected]
Description: Definitions of class Bread. Constructor for Bread instances and Functions "ToString" and "DiscountedPrice".
Done without pair programming and in Visual Studio.
Late Days: none
*/
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;
#include "Bread.h"
Bread::Bread(string breadType) {
ostringstream os;
const int PRECISION = 2;
cout << fixed << setprecision(PRECISION);
price = BREADPRICE;
//this->breadType = breadType;
os << breadType << " bread " << BakedGood::ToString(); //CALL TO BASE CLASS
description = os.str();
}
string Bread::ToString() const {
return description;
}
double Bread::DiscountedPrice(int numGoods) {
double discountedPrice;
const int DISCOUNTNUM = 3;
int freeLoaves;
freeLoaves = numGoods / DISCOUNTNUM;
discountedPrice = (numGoods - freeLoaves) * BREADPRICE;
return discountedPrice;
}