Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * sandwich_template.cpp
- *
- *
- * Created by Eric Weesner on 6/27/11.
- * Copyright 2011 Butte College. All rights reserved.
- *
- */
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- #include "CinReader.h"
- using namespace std;
- CinReader reader;
- const string BREAD[4] = {"Whole Wheat", "White", "Rye", "French Roll"};
- const string MEAT[5] = {"Turkey", "Ham", "Roast Beef", "Pastrami", "Bacon"};
- const string CHEESE[3] = {"Cheddar", "Swiss", "Provolone"};
- const string VEGGIE[3] = {"Lettuce", "Tomato", "Onion"};
- const string CONDIMENT[3] = {"Mayonaise", "Mustard", "Ranch"};
- struct Sandwich
- {
- string bread;
- string meat;
- string cheese;
- string veggie;
- string condiment;
- };
- void intro ();
- /** This function displays the ingredients of a sandwich to a
- * specified output source (i.e. console, file, etc).
- * @param out the generic output source. The programmer must
- * specify the source
- * @param s the user supplied Sandwich
- */
- void display(ostream& out, Sandwich s);
- /** Prints out a receipt for the customer.
- * @ param s the user supplied Sandwich
- */
- void printReceipt(Sandwich s);
- void saveSandwich(Sandwich s);
- /** Reads in the last sandwich made.
- * @param fileAccess, the call by reference boolean expression
- * used to help determine whether a file was opened successfully
- * for reading. NOTE TO PROGRAMMER: This should be set to false
- * if the file can not be opened.
- * @return a sandwich of type Sandwich
- */
- Sandwich readSandwich(bool& fileAccess);
- string breadChoice();
- string meatChoice();
- string cheeseChoice();
- string veggieChoice();
- string condimentChoice();
- int main()
- {
- Sandwich s;
- intro();
- system("cls");
- s.bread = breadChoice();
- system("cls");
- s.meat = meatChoice();
- system("cls");
- s.cheese = cheeseChoice();
- system("cls");
- s.veggie = veggieChoice();
- system("cls");
- s.condiment = condimentChoice();
- system("cls");
- saveSandwich(s);
- cout << s.bread << s.meat << s.cheese << s.veggie << s.condiment;
- return 0;
- }
- void intro()
- {
- char ready;
- //system("clear");
- cout << "HELLO! Welcome to Warren's Sandwich Shop. My sandwich"<< endl
- << "making ability is very limited. Therefore, you will only" << endl
- << "be able to order one sandwich. Your sandwich will may only" << endl
- << "consist of one of each type of the following: " << endl
- << "1. Bread" << endl
- << "2. Meat" << endl
- << "3. Cheese" << endl
- << "4. Vegetable" << endl
- << "5. Condiment" << endl << endl;
- cout << "Are you ready to order (y/n)? ";
- ready = reader.readChar("YyNn");
- if (ready == 'n' || ready == 'N')
- {
- cout << "\nY'all come back now!" << endl << endl;
- exit(0);
- }
- else
- {
- cout << "\nGreat, let's make a sandwich!" << endl;
- cout << "Press enter to continue.";
- reader.readString();
- cout << endl;
- }
- }
- void display(ostream& out, Sandwich s)
- {
- }
- void printReceipt(Sandwich s)
- {
- }
- void saveSandwich(Sandwich s)
- {
- ofstream outFile("savedSandwich.txt");
- outFile << s.bread <<":"
- << s.meat <<":"
- << s.cheese <<":"
- << s.veggie <<":"
- << s.condiment
- << endl;
- }
- /*Sandwich readSandwich(bool& fileAccess)
- {
- ifstream inFile("savedSandwich.txt");
- if(!inFile)
- {
- return false;
- }
- else
- {
- //read file!s
- }
- }
- */
- string breadChoice()
- {
- cout << "\nPlease select a number from the following selection\n\n";
- string bread;
- for(int i=0; i<4; i++)
- {
- cout << i+1 << ". " << BREAD[i] << endl;
- }
- cout << "\n\nWhat bread would you like? ";
- int c = reader.readInt(1,4);
- return BREAD[c-1];
- }
- string meatChoice()
- {
- cout << "\nPlease select a number from the following selection\n\n";
- string meat;
- for(int i=0; i<5; i++)
- {
- cout << i+1 << ". " << MEAT[i] << endl;
- }
- cout << "\n\nWhat Meat would you like? ";
- int c = reader.readInt(1,5);
- return MEAT[c-1];
- }
- string cheeseChoice()
- {
- cout << "\nPlease select a number from the following selection\n\n";
- string cheese;
- for(int i=0; i<3; i++)
- {
- cout << i+1 << ". " << CHEESE[i] << endl;
- }
- cout << "\n\nWhat Cheese would you like? ";
- int c = reader.readInt(1,3);
- return CHEESE[c-1];
- }
- string veggieChoice()
- {
- cout << "\nPlease select a number from the following selection\n\n";
- string veggie;
- for(int i=0; i<3; i++)
- {
- cout << i+1 << ". " << VEGGIE[i] << endl;
- }
- cout << "\n\nWhat Veggie would you like? ";
- int c = reader.readInt(1,3);
- return VEGGIE[c-1];
- }
- string condimentChoice()
- {
- cout << "\nPlease select a number from the following selection\n\n";
- string condiment;
- for(int i=0; i<3; i++)
- {
- cout << i+1 << ". " << CONDIMENT[i] << endl;
- }
- cout << "\n\nWhat Condiment would you like? ";
- int c = reader.readInt(1,3);
- return CONDIMENT[c-1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement