Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Program Name: Ice Cream App
- Program Description: Ice Cream App displays lists all types of ice cream treats that our ice cream shop serves.
- After the user chooses their ice cream treat they can then choose their extras (size, toppings, etc).
- You may search and sort our inventory for readability--and there are several options for receipt delivery.
- Thank you for using our ice cream shop application!
- Programmer Name: Brandon Jinright
- Revision History: Beta Version 0.1
- */
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <stdlib.h>
- #include "data.h"
- using namespace std;
- //function prototypes
- void displayChoices(string*, string*, IceCreamData data, Volume details, Extras customize);
- void purchaseItems(string*, string*, IceCreamData data, Volume details, Extras customize);
- void customizeItems(IceCreamData data, Volume details, Extras customize);
- void searchInventory(IceCreamData data, Volume details, Extras customize);
- void sortInventory(IceCreamData data, Volume details, Extras customize);
- void printToScreen(IceCreamData data, Volume details, Extras customize);
- void printToFile(IceCreamData data, Volume details, Extras customize);
- void menu(IceCreamData data, Volume details, Extras customize);
- int main()
- {
- IceCreamData data;
- Volume details;
- Extras customize;
- const int SIZE = 10;
- string item[SIZE];
- string description[SIZE];
- fstream inputFile;
- inputFile.open("inventory.txt");
- for(int i=0;i<SIZE;i++){
- getline(inputFile, item[i]);
- data.setItemName(item, i);
- getline(inputFile, description[i]);
- data.setDescription(description, i);
- }
- string* items = data.getItemName();
- string* descriptions = data.getDescription();
- /*for(int x=0;x<SIZE;x++){
- cout<<items[x]<<"\n"<<descriptions[x]<<endl;
- }
- */
- inputFile.close();
- menu(data, details, customize);
- return 0;
- }
- void displayChoices(string* items, string* descriptions, IceCreamData data, Volume details, Extras customize){
- const int SIZE = 10;
- for(int i=0;i<SIZE;i++){
- cout<<i+1<<") "<<items[i]<<"\n"<<descriptions[i]<<endl;
- }
- menu(data, details, customize);
- }
- void purchaseItems(string* items, string* descriptions, IceCreamData data, Volume details, Extras customize) {
- string itemName;
- const int SIZE = 10;
- int choice;
- double cost;
- for(int i=0;i<SIZE;i++){
- cout<<i+1<<") "<<items[i]<<endl;
- }
- do{
- cout<<"\nPlease enter selection: ";
- cin>>choice;
- } while(choice<1||choice>10);
- if(choice==1){
- itemName = "Vanilla Delight";
- data.setItemChoice(itemName);
- } else if (choice==2){
- itemName = "Ice Cream Sundae";
- data.setItemChoice(itemName);
- } else if(choice==3){
- itemName = "Strawberry Shortcake Sundae";
- data.setItemChoice(itemName);
- } else if(choice==4){
- itemName = "Brownie Madness";
- data.setItemChoice(itemName);
- } else if(choice==5){
- itemName = "Cookie Dough Madness";
- data.setItemChoice(itemName);
- } else if(choice==6){
- itemName = "Brownie & Cookie Dough Blast";
- data.setItemChoice(itemName);
- } else if(choice==7){
- itemName = "Butter-finger Delight";
- data.setItemChoice(itemName);
- } else if(choice==8){
- itemName = "Pecan Pie Madness";
- data.setItemChoice(itemName);
- } else if(choice==9){
- itemName = "Banana Split";
- data.setItemChoice(itemName);
- } else if(choice==10){
- itemName = "Root-beer Float";
- data.setItemChoice(itemName);
- } else {
- cout<<"Invalid choice!";
- }
- string item = data.getItemChoice();
- cout<<"Thank you! You may now customize your "<< item <<".";
- menu(data, details, customize);
- }
- void customizeItems(IceCreamData data, Volume details, Extras customize) {
- double treatCost;
- int selectionType;
- int selectionSize;
- int toppingQty;
- string type;
- string typeSize;
- string toppings[5];
- cout<<"Would you like a cone or a cup?\n";
- cout<<"1) Cone\n";
- cout<<"2) Cup\n";
- cin>>selectionType;
- if(selectionType==1){
- type = "Cone";
- customize.setType(type);
- } else if(selectionType==2){
- type = "Cup";
- customize.setType(type);
- }
- string treatType = customize.getType();
- cout<<"Which size would you like?\n";
- cout<<"1) Small (3 scoops)\n";
- cout<<"2) Large (5 scoops)\n";
- cin>>selectionSize;
- if(selectionSize==1){
- typeSize = "Small (3 scoops)";
- details.setSize(typeSize);
- } else if(selectionSize==2) {
- typeSize = "Large (5 scoops)";
- details.setSize(typeSize);
- }
- string sizeOfTreat = details.getSize();
- do{
- cout<<"How many toppings would you like? (up to 5)? ";
- cin>>toppingQty;
- cin.ignore();
- } while(toppingQty<1||toppingQty>5);
- for(int i=0;i<toppingQty;i++){
- cout<<"Topping #"<<i+1<<": ";
- getline(cin, toppings[i]);
- customize.setToppings(toppings, i); //set toppings
- }
- string* allToppings = customize.getToppings(); //get toppings, returns null value
- cout<<allToppings;
- /*for(int i=0;i<5;i++){
- cout<<toppings[i];
- } */
- menu(data, details, customize);
- }
- void searchInventory(IceCreamData data, Volume details, Extras customize) {
- cout<<"\n\nSearching inventory. . .";
- main();
- }
- void sortInventory(IceCreamData data, Volume details, Extras customize) {
- cout<<"\n\nSorting inventory. . .";
- main();
- }
- void printToScreen(IceCreamData data, Volume details, Extras customize) {
- cout<<"\n\nPrinting to screen. . .";
- main();
- }
- void printToFile(IceCreamData data, Volume details, Extras customize) {
- cout<<"\n\nPrinting to file. . .";
- main();
- }
- void menu(IceCreamData data, Volume details, Extras customize) {
- string* items = data.getItemName();
- string* descriptions = data.getDescription();
- int selection;
- const int ONE = 1,
- TWO = 2,
- THREE = 3,
- FOUR = 4,
- FIVE = 5,
- SIX = 6,
- SEVEN = 7,
- EIGHT = 8;
- do{
- cout<<"\n\n1. Display Choices of Ice Cream\n";
- cout<<"2. Purchase Ice Cream\n";
- cout<<"3. Customize Ice Cream\n";
- cout<<"4. Search for Item\n";
- cout<<"5. Sort Inventory\n";
- cout<<"6. Print Receipt to screen\n";
- cout<<"7. Print Receipt to file\n";
- cout<<"8. Exit\n\n";
- cout<<"Please enter selection: ";
- cin>>selection;
- } while(selection<1||selection>8);
- switch(selection){
- case ONE:
- displayChoices(items, descriptions, data, details, customize);
- case TWO:
- purchaseItems(items, descriptions, data, details, customize);
- case THREE:
- customizeItems(data, details, customize);
- case FOUR:
- searchInventory(data, details, customize);
- case FIVE:
- sortInventory(data, details, customize);
- case SIX:
- printToScreen(data, details, customize);
- case SEVEN:
- printToFile(data, details, customize);
- case EIGHT:
- exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement