Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Admin
- {
- public:
- void Add_phone();
- void Remove_phone();
- void Update_phone_price();
- Clear_all();
- };
- void Admin::Remove_phone()
- {
- int choice;
- while(true)
- {
- cout<<"Enter Which Type of Phone U want to Delete from the List"<<endl;
- cout<<"1.Featured phone"<<endl;
- cout<<"2.Midrange phone"<<endl;
- cout<<"3.Flagship phone"<<endl;
- cout<<"4.Apple Phone"<<endl;
- cout<<"0.Exit"<<endl;
- cin>>choice;
- if(choice==1)
- {
- fstream fin,fout;
- fin.open("Featuredphone.csv",ios::in);
- fout.open("New1.csv",ios::out | ios::app);
- vector<string>row;
- string line,word,temp;
- int cnt=0;
- cout<<"Enter the Name of Phone U want to Remove"<<endl;
- string name;
- cin>>name;
- while(getline(fin,line))
- {
- row.clear();
- // getline(fin,line);
- stringstream s(line);
- while(getline(s,word,','))
- {
- row.push_back(word);
- }
- if(name==row[0]){
- }
- else
- {
- fout<<row[0]<<","<<row[1]<<","<<row[2]<<endl;
- }
- }
- fin.close();
- fout.close();
- remove("Featuredphone.csv");
- rename("New1.csv","Featuredphone.csv");
- }
- else if(choice==2)
- {
- fstream fin,fout;
- fin.open("Midrangedphone.csv",ios::in);
- fout.open("New1.csv",ios::out | ios::app);
- vector<string>row;
- string line,word,temp;
- int cnt=0;
- cout<<"Enter the Name of Phone U want to Remove"<<endl;
- string name;
- cin>>name;
- while(getline(fin,line))
- {
- row.clear();
- // getline(fin,line);
- stringstream s(line);
- while(getline(s,word,','))
- {
- row.push_back(word);
- }
- if(name==row[0]){
- continue;
- }
- else
- {
- for(int i=0;i<row.size()-1;i++)
- {
- fout<<row[i]<<",";
- }
- fout<<row[row.size()-1]<<endl;
- }
- }
- fin.close();
- fout.close();
- remove("Midrangedphone.csv");
- rename("New1.csv","Midrangedphone.csv");
- }
- else if(choice==3)
- {
- cout<<"Enter the Name of Phone U want to Remove"<<endl;
- string name;
- cin>>name;
- fstream fin,fout;
- fin.open("Flagship_phone.csv",ios::in);
- fout.open("New1.csv",ios::out | ios::app);
- vector<string>row;
- string line,word,temp;
- int cnt=0;
- while(getline(fin,line))
- {
- row.clear();
- // getline(fin,line);
- stringstream s(line);
- while(getline(s,word,','))
- {
- row.push_back(word);
- }
- if(name==row[0]){
- continue;
- }
- else
- {
- for(int i=0;i<row.size()-1;i++)
- {
- fout<<row[i]<<",";
- }
- fout<<row[row.size()-1]<<endl;
- }
- }
- fin.close();
- fout.close();
- remove("Flagship_phone.csv");
- rename("New1.csv","Flagship_phone.csv");
- }
- else if(choice==4)
- {
- cout<<"Enter the Name of Phone U want to Remove"<<endl;
- string name;
- cin>>name;
- fstream fin,fout;
- fin.open("Apple_phone.csv",ios::in);
- fout.open("New1.csv",ios::out | ios::app);
- vector<string>row;
- string line,word,temp;
- int cnt=0;
- while(getline(fin,line))
- {
- row.clear();
- // getline(fin,line);
- stringstream s(line);
- while(getline(s,word,','))
- {
- row.push_back(word);
- }
- if(name==row[0]){
- continue;
- }
- else
- {
- for(int i=0;i<row.size()-1;i++)
- {
- fout<<row[i]<<",";
- }
- fout<<row[row.size()-1]<<endl;
- }
- }
- fin.close();
- fout.close();
- remove("Apple_phone.csv");
- rename("New1.csv","Apple_phone.csv");
- }
- else if(choice==0)
- {
- break;
- }
- else
- {
- continue;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment