//dishes.cpp #include"dishes.h" #include //------------Dish--------- bool Dish::getsDiscount=false; Dish::Dish() { name="Nothing ordered"; price=0.0; } float Dish::getPrice() { if (!getsDiscount) return price; return 0.9*price; } void Dish::printbillitem(ostream & out) { out << setw(20) << name << setw(8) << price ; if (getsDiscount) out << '*'; } void Dish::getchoices() {;} void Dish::setdiscount(bool disc) {getsDiscount=disc;} //----------Sandwich----------- const string Sandwich::maincontent[3]={"Tuna", "Cream Cheese", "Roast Beef"}; const string Sandwich::ontop[5]={"lettuce", "tomato", "mayo", "mustard", "cheese"}; Sandwich::Sandwich() { name="Sandwich"; price=3.75; } void Sandwich::printbillitem(ostream & out) { Dish::printbillitem(out); out << " with " << maincontent[kind_of_sandwich] << endl; } void Sandwich::getchoices() { int choice; cout << "What kind of sandwich would you like?\n"; cout << "1: Tuna\n"; cout << "2: Cream Cheese\n"; cout << "3: Roast Beef\n"; cin >> choice; kind_of_sandwich=choice-1; int count=0; choice=-1; while( choice!=9 && count<5) { cout << "What would you like on your sandwich?\n"; cout << "1: lettuce\n"; cout << "2: tomato\n"; cout << "3: mayonnaise\n"; cout << "4: mustard\n"; cout << "5: cheese\n"; cout << "9: nothing else\n"; cin >> choice; if (choice!=9) topping_choices[count++]=choice-1; } return; } //----------Pasta----------- const string Pasta::sauce[4]={"Tomato sauce", "Meat sauce", "Alfredo sauce", "Plain"}; Pasta::Pasta() { name="Pasta"; price=5.50; } void Pasta::printbillitem(ostream & out) { Dish::printbillitem(out); out << " with " << sauce[sauce_choice] << endl; } void Pasta::getchoices() { int choice; cout << "What would you like on your pasta?\n"; cout << "1: Tomato Sauce\n"; cout << "2: Meat Sauce\n"; cout << "3: Alfredo Sauce\n"; cout << "4: Nothing\n"; cin >> choice; sauce_choice=choice-1; return; }