#include #include #include "order2.H" #include "pizza2.H" using namespace std; // default constructor Order::Order ( ) { nrSodas = 0; nrBreadSticks = 0; nrPizzas = 0; sodaPrice = 1.19; bsPrice = 0.99; } // 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; } // input operator istream& operator>> (istream& in, Order& order) { cout << "What's your name?"; getline (in, order.name); cout << "What's your phone number?"; getline (in, order.phone); cout << "How many sodas?"; in >> order.nrSodas; cout << "How many breadsticks?"; in >> order.nrBreadSticks; cout << "How many pizzas?"; in >> order.nrPizzas; in.ignore(); if (order.nrPizzas != 0) { string yn; cout << "Would you like to see a list of toppings? (yes/no)?"; getline (in, yn); if (yn == "yes") { Pizza p; p.ListToppings(); } } for (int i = 0; i < order.nrPizzas; i++) in >> order.pizzas[i]; return in; }