Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<fstream>
- #include<string>
- using namespace std;
- class Restaurant
- {
- int number,price,amount;
- string name;
- public:
- void Set_Value(int n,string nm,int p,int a)
- {
- number = n;
- name = nm;
- price = p;
- amount = a;
- }
- void show_menu(int i)
- {
- cout<<"#"<<i<<endl;
- cout<<"Name : "<<name<<endl;
- cout<<"Price : "<<price<<endl;
- cout<<"Amount : "<<amount<<endl;
- }
- void show_Bill(int Q)
- {
- cout<<"Name : "<<name<<endl;
- cout<<"quantity: "<<Q<<endl;
- cout<<"Total Bill : "<<price*Q<<endl<<endl;
- cout<<"Thank you!";
- }
- };
- int main()
- {
- Restaurant Manager[20];
- int items,choose,i,v2;
- ofstream savedMenu;
- cout<<"1. Add new items\n"<<"2. Skip"<<endl;
- cin>>v2;
- if(v2==1)
- {
- cout<<"How many items: ";
- cin>>items;
- savedMenu.open("Restaurant Management.txt",ios::app);
- for(int i=1; i<=items; i++)
- {
- int item_no,number,price,amount;
- string name;
- cout<<"Item number: #";
- cin>>item_no;
- savedMenu<<"#"<<item_no<<endl;
- cout<<"Name : ";
- cin>>name;
- savedMenu<<"Name : "<<name<<endl;
- cout<<"Price : ";
- cin>>price;
- savedMenu<<"Price : "<<price<<endl;
- cout<<"Amount : ";
- cin>>amount;
- savedMenu<<"Amount : "<<amount<<endl;
- cin.ignore();
- Manager[i].Set_Value(number,name,price,amount);
- }
- savedMenu.close();
- }
- cout<<"===================================="<<endl;
- cout<<" Welcome to Restaurant"<<endl<<endl;
- cout<<"1. See all"<<endl<<"2. Select "<<endl<<endl;
- cout<<"select :";
- cin>>choose;
- if(choose==1)
- {
- fstream savedMenu("Restaurant Management.txt",ios::in);
- string line;
- while(getline(savedMenu,line))
- {
- cout<<line<<endl;
- }
- savedMenu.close();
- }
- cout<<"Select items : ";
- int selected_item;
- cin>>selected_item;
- int quntty;
- cout<<"select quantity : ";
- cin>>quntty;
- cout<<"\nYou have selected : #"<<selected_item<<endl;
- Manager[selected_item].show_Bill(quntty);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement