Zekorov's Profile User Rating: -----

Reputation: 22 Tradesman
Group:
Active Members
Active Posts:
226 (0.21 per day)
Joined:
16-May 10
Profile Views:
5,169
Last Active:
User is offline Dec 26 2011 07:42 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Chevrolet
Dream Kudos:
0

Latest Visitors

Icon   Zekorov working on DoomGame.... it's coming along so much faster and better than the last time i tried it. Thanks Dogstopper :D

Posts I've Made

  1. In Topic: Power function returning Bad Token

    Posted 26 Dec 2011

    Hello and thanks a lot for your help! I ended up completely ignoring both parenthesis and the comma in between expressions. It was actually something stupid that I didn't take back out when i first was trying to fix bugs. :P haha I'd have to go look again at what I did, and test out the code more, because I clearly didn't get everything right as my grade was 45/50. although I probably could have done the bonus and did the factorial function. that's actually really easy to do recursively.
    edit - sorry I never mentioned what values were output once i had started to get it working just with incorrect output.
  2. In Topic: Sorting a vector of menu_item_ids with their total sales

    Posted 1 Nov 2011

    Hello, Thanks for the reply Baavgai, and thanks for everyone's help, but I did manage to get it done correctly in a much simpler way. it's kind of awesome. I used a double for loop that runs through the last 5 prices i had from the prices vector and then simply erases the last used price once it was matched up to an ID, while the ID was also erased from its respective vector, and then the original price was also in its own vector, and being erased to keep everything orderly. and it worked out just fine. :) Basically, i forced the program to quit using the same id more than once and so it worked out. :)

    In a little while, I will be asking another question having to do with this program, and since the code is already in this thread, I thought I wouldn't start a new thread to ask about it. But first, I have to finish my history lecture. So, please sit tight and don't go away just yet. I still would like understanding and help. (By the way, this is a new part of the project I will ask about, having to do with writing back out to the files that are used to get the information in the first place.)
  3. In Topic: Sorting a vector of menu_item_ids with their total sales

    Posted 26 Oct 2011

    urhm..... i don't know about that either.... i'm super tired of doing this though. been working on it for 3 days. so, i'm just calling it a night and i'm gonna turn in what i have, and see how that goes.... i can't waste any more time on trying to figure this out, it's really cutting into me studying for my math exam tomorrow, or doing my chemistry lab report due friday. So, thank you much for your help, and have a good night, i apologize that i wasted your time and didn't get to finish this.
  4. In Topic: Sorting a vector of menu_item_ids with their total sales

    Posted 26 Oct 2011

    sigh.... if you have to see it all.... here it goes.....
    //p1_main.cpp
    //============================================================================
    // Name        : p1_main.cpp
    // Author      : 
    // Version     :
    // Copyright   : Your copyright notice
    // Description : C++ project part I for CSCE 121 and IF4093 
    //============================================================================
    //
    
    #include "Menu.h"
    #include <iostream>
    
    using namespace std;
    
    int main()
    try {
       Menu m;
       int option;
      
       m.display_main_menu();
       do {
          cout << "> ";
    	  while (!(cin >> option) || option < Menu::Info || option > Menu::Exit) {
             if (cin.fail()) {    // we found something that wasn’t an integer 
                cin.clear();      // enable us to look at the characters
                char ch;
                while (cin>>ch && !isdigit(ch)) {
                   cerr << "Invalid input; please try again" << endl;
                   cout << "> ";
                }
                cin.unget();
             } else {  // option < Menu::Info || option > Menu::Exit */
                cerr << "Invalid input; please try again" << endl;
                cout << "> ";
             }
          } 
    			
          switch(option) { 
          case Menu::Info:
             m.display_info();//display assignment info & your names plus "Project 1"
             break;
    	  case Menu::Read:
             try {
                m.read();
             } catch (const Menu::InvalidFile& excp) {
                cerr << excp.what() << endl;
             } catch (const Menu::InvalidData& excp) {
                cerr << excp.what() << endl;
             }
             break;
    	  case Menu::Find:
             m.find();
             break;
    	  case Menu::Show:
               
             m.show();
             break;
    	  case Menu::Update:
             m.update();
             break;
          }
    	  
          m.display_main_menu();
          if(option == Menu::Exit)
          {
                    string confirm;
    
                    cout<< "Are you sure you want to exit? (6 to confirm exit, 1-5 to cancel exit)\n";
                    cin >> option;
                    if (option == 6)
                            break;
                    else
                    {
    			m.display_main_menu();
    		}
          }
    
       } while (option != Menu::Exit);
       return 0;
    }
    catch (exception& e) {
    	cerr << e.what() << endl;   
    }
    catch (...) {
    	cerr << "unknown exception\n";
    }
    
    //all of menu.cpp
    #include "Menu.h"
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <algorithm>
    //additional includes
    
    using namespace std;
    
    Menu::Menu()
    {
    }
    
    // class c for Part C.2 by Colt Campbell
    // to compare prices and get both menu_item_ids and total revenue into one vector
    class c
    {
          public: 
                  
                 c (int id, double pr):menu_id(id), price(pr) {};
           
          
                 int menu_id;
                 double price;
                 
          
        
          c& c::operator<(const c &rhs)
          {
                 price < rhs.price;
                 return *this;     
          }
    };
    
    void Menu::display_main_menu() const 
    {
    	cout << "Here is the MAIN MENU \n";
    	cout << "Press a number corresponding to an option to go into that option.\n";
    	cout << "1 is for Info\n";
    	cout << "2 is for reading in data\n";
    	cout << "3 is for showing a query\n"; 
    	cout << "4 is for finding a query\n";
    	cout << "5 is for updating the query\n";
    	cout << "6 is to quit.\n\n";
    }
    void Menu::display_info() const
    {
    	cout << "Here is the Info requested \n";
    	cout << "Part B Team ROMS Project Part I\n";
    	cout << "Colt Campbell, Daniel Fernandez, Jerry Behm\n";
    	cout << "Colt Campbell did parts B.3 and B.2 b/c\n";
    	cout << "Daniel Fernandez did parts B.1 and B.2 a/b\n";
    	cout << "Jerry Behm did no parts.\n\n";
    	 
    }
    
    void Menu::read()
    {
    	cout << "Read file name then store data \n";
    	ifstream file;
    	file.open("orders.dat");
    	if(file.is_open())
    	{
    		int counter;
    		int o_id, s_id, t_id, y,m,d,h,min;
    		file >> counter;
    		for(int i = 0; i < counter; i++)
    		{
    			file >> o_id;
    			file >> s_id;
    			file >> t_id;
    			file >> y;
    			file >> m;
    			file >> d;
    			file >> h;
    			file >> min;
    		Menu::orders.push_back(Order(o_id,s_id,t_id,Date(y,m,d),Time(h,min)));	
    		}
    		char seat;
    		int  item_id, quantity;
    		file >> counter;
    		for(int i = 0; i < counter; i++)
    		{
    			file >> seat;
    			file >> o_id;
    			file >> item_id;
    			file >> quantity;
    		Menu::order_items.push_back(Order_Item(seat,o_id,item_id,quantity));
    		}
    	}
    	file.close();
    
    	ifstream file2;	// CC part A.1
    	file2.open("recipes.dat");
    	if(file2.is_open())
    	{
            // Read For Ingredients
    		int counter;
    		int i_id, r_id;
    		float amt;
    		string units, name;
    		file2 >> counter;
    		for(int i = 0; i < counter; i++)
    		{
    			file2 >> i_id;
    			file2 >> r_id;
    			file2 >> amt;
    			file2 >> units;
    			file2 >> name;
    			Menu::ingredients.push_back(Ingredient(i_id,r_id,amt,units,name));
    		}
    		string chef;
    		string recipe;
    		string s;
    		file2 >> counter;
    		for(int i = 0; i < counter; i++)
    		{
    			file2 >> r_id;
    			file2 >> chef;
    			getline(file2,s,'#');
    			
    			Menu::recipes.push_back(Recipe(r_id,chef,Instructions(s)));
    		}
    		
    	}
    	file2.close();
    	
    	ifstream file3; 
            file3.open("catmenu.dat");
            if (file3.is_open()) 
    	{
    		//Read For Categories
    		int counter;
    		int id;
    		string name;
    		file3 >> counter;
    		
    		for(int c = 0; c< counter; c++)
    		{
    				file3 >> id;
    				file3 >> name;
    				Menu::categories.push_back(Category(id,name));
    		}
    		//Read for Menu Items
    		int categ ;
    		int rec;
    		double amt;
    		string dez;
        
    		file3 >> counter;
    		for(int c = 0; c < counter; c++)
    		{
    			    file3 >> id;
    				file3 >> categ;
    				file3 >> rec;
    				file3 >> name;
    				file3 >> amt;
    				char c = '#';
    				getline(file3, dez, c);
    				Menu::menu_items.push_back(Menu_Item(id,categ,rec,name,amt,Description(dez)));
    		}
    	}
    	file3.close();
    }
    // Put in > before prompt cin
    void Menu::show() //Daniel F.
    {
        int choice;
    	cout << "Would you like to 1) Show a Menu Item Recipe 2)Print all menu items sorted " <<
                " by chef 3) Print items by Category, sorted by price.  Type 1,2,3 \n";
        cin >> choice;
        switch(choice) {
        case 1:
             //list menu items
             cout << "Choose a Recipe: " << endl;
             for(int i = 0; i < Menu::menu_items.size(); i++){
             cout << i+1 << ") " << Menu::menu_items.at(i).getName() << endl; 
             }
             //switch for menu items
             cin >> choice;
             choice--;
             cout << Menu::menu_items[choice].getName() << ":" << endl;
             cout << "Description  - " << Menu::menu_items[choice].getDescription() << endl << endl;
             //Check ingredients for 
             cout << "Ingredients  - " <<  endl;
             for(int a = 0;a < Menu::ingredients.size(); a++){
                     if(Menu::ingredients[a].getRecipeId() == Menu::menu_items[choice].getRecipeId())
                     {cout << Menu::ingredients[a].display() << endl;}
                     } cout << endl;
             cout << "Instructions - " << endl;
             for(int a = 0;a < Menu::recipes.size(); a++){
                     if(Menu::recipes[a].getRecipeId() == Menu::menu_items[choice].getRecipeId())
                     {cout << Menu::recipes[a].showInstructions() << endl << endl;}
                     }
        break;
        case 2:{
                  vector<Menu_Item> iteminfo = Menu::menu_items; 
                  vector<Recipe> trecipe = Menu::recipes;
                  vector<string> chefs;
                  for(int a = 0; a < Menu::recipes.size(); a++){
                          chefs.push_back(Menu::recipes[a].getChef());
                          }
                  //sort recipes
                  sort(chefs.begin(),chefs.end());
                  //compare menu item to order item then check if chef == 
                  while(chefs.size() != 0){
                          for(int d = 0;d < chefs.size();d++){
                                  if(chefs[0].compare(trecipe[d].getChef()) == 0){
                                        for(int c = 0; c < iteminfo.size();c++){
                                            if(trecipe[d].getRecipeId() == iteminfo[c].getRecipeId()){
                                                                       cout << "Chef:  " << chefs[0] << endl;
                                                                       cout << "Recipe:  " << iteminfo[c].getName();
                                                                       cout << "     ID:  " << iteminfo[c].getRecipeId();
                                                                       cout << "   Price:  " << iteminfo[c].getPrice() << endl;  
                                                                       chefs.erase(chefs.begin());
                                                                       trecipe.erase(trecipe.begin() + d);
                                                                       iteminfo.erase(iteminfo.begin()+c);
                                                                       } 
                                                    
                                        }
                                  }
                           }
                  }
                             
        break;}
        case 3:
             vector<Menu_Item> items;
             vector<double> prices;
             int choice;
             //pick a category
             cout << endl << "Pick a category: " << endl;
             for(int a = 0; a< Menu::categories.size(); a++){
                     cout << a + 1 << ") " << categories[a].toString() << endl;
                     }
             cin >> choice;
             choice--;
             for(int b = 0; b < Menu::menu_items.size(); b++){
                     if(Menu::menu_items[b].getCatId() == categories[choice].getCatId()){
                                                       items.push_back(Menu::menu_items[b]);
                                                       }
                     }
             for(int c = 0; c < items.size(); c++){
                     prices.push_back(items[c].getPrice());
                     }
                     
             //sort by price
             sort(prices.begin(),prices.end());
             
             //print
             while(prices.size() != 0){
                            
             for(int d =0; d < prices.size(); d++){
                     if(prices[0] == items[d].getPrice()){
                                  cout << "Name:  " << items[d].getName()<< "    Price: " << items[d].getPrice() << endl;
                                  cout << "Description:  " << items[d].getDescription() << endl << endl;
                                  items.erase(items.begin()+d);
                                  prices.erase(prices.begin());
                                  }
                     
                     }
                     }
        break;}
    		
    }
    
    void Menu::find() //Daniel F.
    {
         int choose;
         cout << "Would you like to, \n"; 
         cout << "1) Display total sales for a given table.\n";
         cout << "2) Display total sales for a given server.\n";
         cout << "3) Display total sales for a given Menu Item.\n";
         cout << "4) Display the top five selling menu items by revenue.\n";
         cout << "5) Display the order with the largest tab price.\n";
         cout << "type (1,2,3,4,5)" << endl;
         cin >> choose;
         
         switch(choose){
         case 1:{
              //get tables
              vector<int> tablenumbers;
              int f = 1;
              for(int a = 0;a < Menu::orders.size();a++){
              f = 1; if(f == 1){tablenumbers.push_back(Menu::orders[a].getTableId());}
                      for(int b= 0;b < tablenumbers.size(); b++){
                      if(Menu::orders[a].getTableId() == tablenumbers[b]){
                                                      f=0;
                                                      } 
                      }
              
              }
              //choose table
              int choice;
              cout << "Pick a table: " << endl;
              for(int b = 0; b < tablenumbers.size();b++){
                      cout << b + 1 << ") " << tablenumbers[b] << endl;
                      }
              cin >> choice;
              choice--;
              //make vector with all orders from table
              vector<Order> tableorders;
              //check menu::orders table id to choice
              for(int a = 0; a < Menu::orders.size();a++){
                      if(tablenumbers[choice] == Menu::orders[a].getTableId()){
                                              tableorders.push_back(Menu::orders[a]);
                                              }
                      
                      }
              //find order items
              vector<Order_Item> ordered;
              for(int a = 0; a < Menu::order_items.size();a++){
                      for(int b=0;b < tableorders.size();b++){
                      if(Menu::order_items[a].getOrderId() == tableorders[b].getOrderId()){
                                                           ordered.push_back(Menu::order_items[a]);
                                                           }
                                                           }
                      
                      }
              //order items to menu items
              vector<Menu_Item> ordermenu;
              for(int a = 0; a <ordered.size();a++){
                      for(int b=0;b <  Menu::menu_items.size();b++){
                      if(ordered[a].getMenuId() == Menu::menu_items[b].getMenuId()){
                                                           ordermenu.push_back(Menu::menu_items[b]);
                                                           }
                                                           }
                      
                      }
              //add price and print
              double pprice =0;
              for(int a = 0; a < ordermenu.size();a++){
                      pprice += ordermenu[a].getPrice();
                      }
              cout << "Table: " << tablenumbers[choice] << "   Total Sales:  " << pprice<< endl;
              
         break;}   
         case 2:{
              //get servers
              vector<int> servernumbers;
              int f = 1;
              for(int a = 0;a < Menu::orders.size();a++){
              f = 1; if(f == 1){servernumbers.push_back(Menu::orders[a].getServerId());}
                      for(int b= 0;b < servernumbers.size(); b++){
                      if(Menu::orders[a].getServerId() == servernumbers[b]){
                                                      f=0;
                                                      } 
                      }
              
              }
              //choose server
              int choice;
              cout << "Pick a Server: " << endl;
              for(int b = 0; b < servernumbers.size();b++){
                      cout << b + 1 << ") " << servernumbers[b] << endl;
                      }
              cin >> choice;
              choice--;
              //check orders for server
              vector<Order> orderserved;
              //Colt Campbell from here down (working off of Daniel's code)
              for(int a = 0; a < Menu::orders.size();a++)
              {
                      if(servernumbers[choice] == Menu::orders[a].getServerId()){
                                              orderserved.push_back(Menu::orders[a]);
                                              }
              }
              
              //find the order items from the orders found from the servers
              vector<Order_Item> s_orders;
              for (int a = 0; a < Menu::order_items.size(); a++)
              {
                       for (int b = 0; b < orderserved.size(); b++)
                       {
                           if(Menu::order_items[a].getOrderId() == orderserved[b].getOrderId()){
                                                           s_orders.push_back(Menu::order_items[a]);
                                                           }
                           }
              }
              
              // connects  the order items to menu items in order to connect to prices of items
              vector<Menu_Item> s_ordermenu;
              for (int a = 0; a < s_orders.size(); a++)
              {
                       for (int b = 0; b < Menu::menu_items.size(); b++)
                       {
                                if(s_orders[a].getMenuId() == Menu::menu_items[b].getMenuId())
                                {
                                    s_ordermenu.push_back(Menu::menu_items[b]);                      
                                }    
                       }    
              }
              
              //add price and print
              double pprice =0;
              for(int a = 0; a < s_ordermenu.size();a++){
                      pprice += s_ordermenu[a].getPrice();
                      }
              cout << "Server: " << servernumbers[choice] << "   Total Sales:  " << pprice<< endl;
         break;}
         // case 3 by Colt C. (based off of Daniel Fernandez's code in B.2 a)    
         case 3:{
              //gets all the possible menu items
              vector<int> item_numbers;
              int f = 1;
              for(int a = 0;a < Menu::menu_items.size();a++){
              f = 1; if(f == 1){item_numbers.push_back(Menu::menu_items[a].getMenuId());}
                      for(int b= 0;b < item_numbers.size(); b++){
                      if(Menu::menu_items[a].getMenuId() == item_numbers[b]){
                                                      f=0;
                                                      } 
                      }
              
              }
              //choose specific menu item to get total sales of
              int choice;
              cout << "Pick a Menu Item: " << endl;
              for(int b = 0; b < item_numbers.size();b++){
                      cout << b + 1 << ") " << item_numbers[b] << endl;
                      }
              cin >> choice;
              choice--;
              
              //add up the total orders of the specific item
              vector<Order_Item> count;
              for (int a = 0; a < Menu::order_items.size(); a++)
              {
                       if(item_numbers[choice] == Menu::order_items[a].getMenuId()){
                                              count.push_back(Menu::order_items[a]);
                                              }
              }
              //now take all of the orders and price them up
              double pprice = 0;
              pprice = Menu::menu_items[choice].getPrice()*count.size()*1.00;
              cout << "The total sales of " << Menu::menu_items[choice].getMenuId() << " is " << pprice <<"\n\n";
         
         break;}
         case 4:{//Part C.2 by Colt Campbell
              //implement code to display top 5 selling items by revenue
              vector<int> items;
              int f = 1;
              for(int a = 0;a < Menu::menu_items.size();a++){
              f = 1; if(f == 1){items.push_back(Menu::menu_items[a].getMenuId());}
              
              }
              //gets the quantity and amount of times an item was ordered
              int count = 0;
              int diff = 0;
              vector<int> order_times;
              for (int i = 0; i < items.size(); i++)
              {
                    for (int j = 0; j < Menu::order_items.size(); j++)
                    {
                         if (Menu::order_items[j].getMenuId() == items[i])
                         {
                                 count += 1; 
                                 if (Menu::order_items[j].getProQ() > 1)
                                 {
                                      diff = Menu::order_items[j].getProQ() - 1;
                                      count += diff;
                                      diff = 0;                           
                                 }                                                                                          
                         }          
                    }
                    order_times.push_back(count);
                    count = 0;
              }
              //gets the prices of the items and multiplies it by their counts to get total revenue for each item
              vector<double> prices;
              for (int i = 0; i < order_times.size(); i++)
              {
                       prices.push_back(order_times[i]*Menu::menu_items[i].getPrice());
              }
              vector<c> id_price;
              for (int i = 0; i < items.size(); i++)
              {
                  
              } 
              
              //need to figure out how to sort the menu_item_ids based on the sorted prices.
              // that way i can print out the top 5 selling items by revenue
              // output should be similar to or exactly the same as follows:
              // 5. item: 2659 with sales of 57 dollars
              // 4. item: 2712 with sales of 76 dollars
              // 3. item: 2760 with sales of 80 dollars
              // 2. item: 2209 with sales of 100 dollars
              // 1. item: 2980 with sales of 100 dollars
              
              break;
              }
         case 5:{//Part C.2 by Colt Campbell
              //wasted too much time on the first part of C.2, and couldn't get to this part. 
              // basically, you just gather all the tab prices for all of the items, and then sort them. 
              // take out the largest tab price, and then connect it to the appropriate menu_item_id, 
              // then display that menu_item_id. I know that is what you must do, but like the first part of C.2, 
              // i do not know exactly how to implement that logic into code. 
              //implement code to display item with largest tab price
              break;
              }}  
    }
    void Menu::update()  //Colt c.
    {
    	// add new items with cin >> and then push_back into the correct vector
    	//part B.3 (a) by Colt Campbell
    	int seat_id, order_id, menu_item_id, prod_qty;
    	cout << "Please type in the seat id, order id, menu item id, and amount you want\n";
    	cout << "of the order item, respectively.\n\n";
    	cin >> seat_id;
    	cin >> order_id;
    	cin >> menu_item_id;
    	cin >> prod_qty;
    	order_items.push_back(Order_Item(seat_id,order_id,menu_item_id,prod_qty));
    	//part B.3 (B)/> by Colt Campbell
    	cout << "Please type in the id, category id, and recipe id. \n";
    	cout << "Then type in the menu item name, and then price.\n";
    	cout << "Last, type in the description of the new menu item.\n\n";
    	int id, cat, rec;
    	string n, des;
    	double amt;
    	cin >> id;
    	cin >> cat;
    	cin >> rec;
    	cin >> n;
    	cin >> des;
    	cin >> amt;
    	menu_items.push_back(Menu_Item(id,cat,rec,n,amt,Description(des)));
    	//part B.3 (c) by Colt Campbell
    	categories.push_back(Category(1,"Soups"));
    	categories.push_back(Category(2,"Salads"));
    	categories.push_back(Category(3,"Sides"));
    }
    
    //all of menu.h
    #include "Category.h"
    #include "Menu_Item.h"
    #include "Recipe.h"
    #include "Ingredient.h"
    #include "Order.h"
    #include "Order_Item.h"
    #include "Description.h"
    #include "Instructions.h"
    
    using namespace std;
    
    class Menu {
    public:
       struct InvalidData : std::runtime_error {
          InvalidData(): runtime_error("Invalid input data format") {}
       };
    
       struct InvalidFile : std::runtime_error {
          InvalidFile(): runtime_error("Invalid input file name") {}
       };
    
       enum Main_menu_options{ Info=1, Read, Show, Find, Update, Exit }; 
    		
    	Menu();
       
       void display_main_menu() const;
       void display_info() const;//display assignment info & your name plus "Project Part I"
       void read();		 
       void update();
       void show();
       void find();
    
    private:
       //private data
    	vector<Category> categories;
    	vector<Menu_Item> menu_items;
    	vector<Recipe> recipes;
    	vector<Ingredient> ingredients;
    	vector<Order> orders;
    	vector<Order_Item> order_items;
    };
    
    #endif //MENU_H_
    
    
    //menu_item.h
    #ifndef MENU_ITEM_H_
    #define MENU_ITEM_H_
    
    #include <string>
    
    // other types
    #include "Description.h"				//uncomment once you have added the type definition
    using namespace std;
    
    struct Menu_Item
    {
    public:
    	// constructors
    	Menu_Item (int id, int cat, int rec, string n, double amt, Description s)	//uncomment once you have added the type definition
    		: menu_item_id(id), cat_id(cat), recipe_id(rec), menu_item_name(n), price(amt), descr(s) {}
    
       // utility functions
    	string display() const;
    	string getDescription() {return descr.toString();}     
    	string getName() {return menu_item_name;}
    	int getRecipeId() {return recipe_id;}
    	double getPrice() {return price;}
    	int getCatId() {return cat_id;}
    	int getMenuId() {return menu_item_id;}
    
    private:
       //constants
         
       // private data
    	int menu_item_id;
    	int cat_id;
    	int recipe_id;
    	string menu_item_name;
    	double price;
    	Description descr;			//uncomment once you have added the type definition
       
    };
    
    
    #endif //MENU_ITEM_H_
    
    //category.h
    /*
    	The directives starting with # below ensures that this file is read by the compiler only once
    	even if it is #included several times. It is call an "include guard"
    */
    #ifndef CATEGORY_H_
    #define CATEGORY_H_
    
    #include <string>
    #include "Description.h"
    
    using namespace std;
    
    struct Category {
    public:
    	// constructors
    	Category (int id, string name): cat_id(id), cat_name(name) {}
    
        // utility functions
    	string display() const;
    	string toString() {return cat_name;}
    	int getCatId() {return cat_id;}
    
    private:
       //constants
         
       // private data
    	int cat_id;
    	string cat_name;
    };
    
    
    #endif //CATEGORY_H_
    
    //description.h
    #ifndef DESCRIPTION_H_
    #define DESCRIPTION_H_  //DF did this file
    
    #include <string>
    
    using namespace std;
    
    struct Description
    {
    public:
        Description() {}
    	Description(string Dez) : item_Description(Dez) {};
    
        // utility functions
    	string display() const;
    	string toString() {return item_Description;}
    
    private:
       //constants
         
       // private data
    	string item_Description;
       
    };
    
    
    #endif //DESCRIPTION_H_
    
    //ingredient.h
    #ifndef INGREDIENT_H_
    #define INGREDIENT_H_
    
    #include <string>
    #include <iostream>
    #include "Description.h"
    #include <sstream>
    using namespace std;
    
    
    struct Ingredient {
    public:
    	// constructors
    	Ingredient () {}
    	Ingredient (int a, int b, float c, string d, string e) : 
                         ingredient_id(a),recipe_id(B)/>,amt(c), units(d),name(e){};
       // utility functions
    	string display() {
               string s = "";
               stringstream ss (stringstream::in | stringstream::out);
               ss << amt;
               s += ss.str();
               s += " "; s += units; s += " of "; s += name;
               return s;}
               
    	int getRecipeId() {return recipe_id;}
    
    private:
       //constants  
    
       // private data
    	int ingredient_id;
    	int recipe_id;
    	float amt;
    	string units;
    	string name;
    };
    
    
    #endif //INGREDIENT_H_
    
    //order.h
    /*
    	The directives starting with # below ensures that this file is read by the compiler only once
    	even if it is #included several times. It is call an "include guard"
    */
    #ifndef ORDER_H_
    #define ORDER_H_
    
    //other types		
    
    #include "Date.h"			//uncomment once you have added the type definition	
    #include "Time.h"			//uncomment once you have added the type definition
    #include <string>
    
    using namespace std;
    
    struct Order {
    public:
    	//data
    
    	// constructors
    	Order (){}
    	Order (int a, int b, int c, Date d, Time e)
                   : order_id(a),server_id(B)/>,table_id(c), order_date(d), order_time(e) {}
       // utility functions
       int getTableId() {return table_id;}
       int getOrderId() {return order_id;}
       int getServerId() {return server_id;}
    	string display() const;
    private:
       //constants
    
       // private data
    	int order_id;
    	int server_id;
    	int table_id;
    	Date order_date;	//uncomment once you have added the type definition
    	Time order_time;	//uncomment once you have added the type definition
    };
    #endif //ORDER_H_
    
    //order_item.h
    #ifndef ORDER_ITEM_H_
    #define ORDER_ITEM_H_
    
    #include <string>
    using namespace std;
    
    
    struct Order_Item {
    public:
    	// constructors
    	Order_Item () {}
    	Order_Item(char a,int b,int c, int d ) 
                        : seat_id(a), order_id(B)/>, menu_item_id(c), prod_qty(d){}
    
       // utility functions
    	string display() const;
    	int getOrderId() {return order_id;}
    	int getMenuId() {return menu_item_id;}
    	int getProQ() {return prod_qty;}
    
    private:
       //constants  
    
       // private data
    	char seat_id;
    	int order_id;
    	int menu_item_id;
    	int prod_qty;
    };
    
    
    #endif //ORDER_ITEM_H_
    
    //recipe.h
    #ifndef RECIPE_H_
    #define RECIPE_H_
    
    #include <string>
    
    // other types
    #include "Instructions.h"				//uncomment once you have added the type definition
    using namespace std;
     
    struct Recipe {
    public:
    	// constructors
    	Recipe (int id, string n, Instructions a): recipe_id(id), chef_name(n), instr(a) {}
    
       // utility functions
    	string display() const;
    	Instructions returnInstructions() {return instr;}
    	string showInstructions() {return instr.toString();}
    	int getRecipeId() {return recipe_id;}
    	string getChef() {return chef_name;}
    private:
       //constants
         
       // private data
    	int recipe_id;
    	string chef_name;
    	Instructions instr;			//uncomment once you have added the type definition
    };
    
    
    #endif //RECIPE_H_
    
    //instruction.h
    #ifndef INSTRUCTIONS_H_
    #define INSTRUCTIONS_H_ 
    
    #include <string>
    #include "Description.h"
    using namespace std;
    
    struct Instructions
    {
        public:
    	Instructions(){}
    	Instructions(string a) : ins(a) {}
    
    	//utility functions
        string toString() {return ins;}
    
        private:
    	string ins;
    };
    #endif //INSTRUCTIONS_H_
    
    

    and there you go, all of the code that we have so far. then there are three .dat files that accompany this, they are order, recipe, and catmenu which contains the categories, the menu_items, and their prices. by the way, most of this code is relatively unchanged. most of our work has been in Menu.cpp
  5. In Topic: Sorting a vector of menu_item_ids with their total sales

    Posted 26 Oct 2011

    so with what i had above, what needs to be done to do what i need overall? my student instructor said or thought the method i'm using would work, but i just need a little help finishing it. after this, the second part of this that i have to do should be much easier. i understand and thank you all for the criticism of my work, but not all of it is totally my fault. i'm having to work around code framework that was provided for us. I will keep all of the bad implementations in mind for when i get to make my own programs. :) but, right now i just want help with the thing i'm trying to do. if it can be done that way. I want class c to help me get a vector that can take both an int and a double, and then help me sort the vector based on the double. that's it. the rest is easy.

My Information

Member Title:
D.I.C Head
Age:
20 years old
Birthday:
September 15, 1992
Gender:
Location:
United States
Interests:
Chess, programming, guitar, piano, organ, video games. :)
Years Programming:
0
Programming Languages:
(learning them) Java, C++, and VB

Contact Information

E-mail:
Click here to e-mail me
Yahoo:
Yahoo  archangelofheaven@yahoo.com

Comments

Zekorov has no profile comments yet. Why not say hello?