#include #include #include "order1.H" #include "pizza1.H" using namespace std; // default constructor Order::Order ( ) { nrSodas = 0; nrBreadSticks = 0; nrPizzas = 0; sodaPrice = 1.19; bsPrice = 0.99; } // mutators void Order::SetName (string n) { name = n; } void Order::SetPhone (string ph) { phone = ph; } void Order::SetPizza( Pizza p) { pizzas[nrPizzas++] = p; } void Order::SetNrBreadSticks (int n) { nrBreadSticks = n; } void Order::SetNrSodas (int n) { nrSodas = n; } // output operator ostream& operator<< (ostream& out, const Order& order) { double total = 0.0; out << "Your order: " << endl << endl; out << "Name: " << order.name << endl; out << "Phone: " << order.phone << endl; out << endl; double sodaCost = order.nrSodas * order.sodaPrice; total += sodaCost; out << order.nrSodas << " soda(s):\t$"; out.setf (ios::showpoint | ios::fixed); out << setprecision(2) << setw(6) << sodaCost << endl; double bsCost = order.nrBreadSticks * order.bsPrice; total += bsCost; out << order.nrBreadSticks << " breadsticks:\t$" ; out.setf(ios::showpoint | ios::fixed); out << setprecision(2) << setw(6) << bsCost << endl; out << endl; double pizzaCost = 0.0; if (order.nrPizzas == 0) out << "0 Pizzas\t$ 0.00"; for (int i = 0; i < order.nrPizzas; i++) { out << order.pizzas[i]; pizzaCost += order.pizzas[i].GetPrice( ); } out << endl; total += pizzaCost; out.setf(ios::showpoint | ios::fixed); out << "Total cost:\t$" << setprecision(2) << setw(6) << total << endl; return out; }