-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
110 lines (106 loc) · 3.4 KB
/
main.cpp
File metadata and controls
110 lines (106 loc) · 3.4 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
#include <iomanip>
#include "Bread.h"
#include "LayerCake.h"
#include "CupCake.h"
#include <string>
#include <vector>
using namespace std;
int main() {
string orderedItem;
string sprinkleColor;
string frostingType;
string breadType;
string cakeFlavor;
int layerCount;
int itemQuantity;
int itemCounter;
int totalItemCount;
double orderPrice;
vector<BakedGood*> orderedItems;
vector<string> alreadyCounted;
cout << "**Bread and Cakes Bakery**" << endl << endl;
cout << "Enter sub-order (enter \"done\" to finish)" << endl;
breadType = "none";
while(orderedItem != "done"){
cout << "Sub-order: ";
cin >> orderedItem;
cin.ignore();
if(orderedItem == "Bread"){
cin >> breadType;
cin.ignore();
cin >> itemQuantity;
cin.ignore();
for(int i = 0; i < itemQuantity; ++i) {
orderedItems.push_back(new Bread(breadType));
}
}
if(orderedItem == "Cupcake"){
cin >> cakeFlavor;
cin.ignore();
cin >> frostingType;
cin.ignore();
cin >> sprinkleColor;
cin.ignore();
cin >> itemQuantity;
cin.ignore();
for(int i = 0; i < itemQuantity; ++i) {
orderedItems.push_back(new CupCake(cakeFlavor, frostingType, sprinkleColor));
}
}
if(orderedItem == "Layer-cake"){
cin >> cakeFlavor;
cin.ignore();
cin >> frostingType;
cin.ignore();
cin >> layerCount;
cin.ignore();
cin >> itemQuantity;
cin.ignore();
for(int i = 0; i < itemQuantity; ++i) {
orderedItems.push_back(new LayerCake(cakeFlavor, frostingType, layerCount));
}
}
cout << endl;
}
cout << endl;
cout << "Order Confirmations: " << endl;
for(int i = 0; i < orderedItems.size(); ++i){
cout << orderedItems[i]->ToString();
cout << endl;
}
cout << endl;
cout << "Invoice:" << endl;
cout << "Baked Good" << setw(77) << "Quantity" << setw(9) << "Total" << endl;
orderPrice = 0.0;
totalItemCount = 0;
for(int i = 0; i < orderedItems.size(); ++i){
bool checker = false;
itemCounter = 0;
alreadyCounted.push_back("word");
for(int k = 0; k < alreadyCounted.size(); ++k){
if(alreadyCounted.at(k) == orderedItems.at(i)->ToString()){
checker = true;
continue;
}
}
if(checker == true){
continue;
}
else{
for(int j = 0; j < orderedItems.size(); ++j){
if(orderedItems.at(i)->ToString() == orderedItems.at(j)->ToString()){
++itemCounter;
}
}
totalItemCount += itemCounter;
orderPrice += orderedItems.at(i)->DiscountedPrice(itemCounter);
cout << orderedItems.at(i)->ToString() << setw(77) << itemCounter << setw(9);
cout << fixed << setprecision(2) << orderedItems.at(i)->DiscountedPrice(itemCounter) << endl;
}
alreadyCounted.push_back(orderedItems.at(i)->ToString());
}
cout << "Totals" << setw(77) << totalItemCount << setw(9) << orderPrice << endl;
cout << "Goodbye" << endl;
return 0;
}