Guest User

Untitled

a guest
Sep 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Loop for instream from file
  2. ifstream furniture;
  3. furniture.open("h://furniture.txt");
  4.  
  5.  
  6. for(int i=0;i<=count;i++)
  7. {
  8. type=0;
  9. furniture>>type>>name>>number>>material>>colour>>mattress;
  10.  
  11. switch (type)
  12. {
  13. case 1:
  14. {
  15. Item* item= new Bed(number, name, material, colour, mattress);
  16. cout<<"working, new bed"<<endl;
  17. v.push_back(item);
  18. cout<<"working pushback"<<endl;
  19. count++;
  20.  
  21. break;
  22. }
  23. case 2:
  24. {
  25. Item* item= new Sofa(number, name, material, colour);
  26. cout<<"working, new sofa"<<endl;
  27. v.push_back (item);
  28. cout<<"working pushback"<<endl;
  29. count++;
  30.  
  31. break;
  32. }
  33. case 3:
  34. {
  35. Item* item= new Table(number, name, material, colour);
  36. cout<<"working, new table"<<endl;
  37. v.push_back(item);
  38. cout<<"working pushback"<<endl;
  39. count++;
  40.  
  41. break;
  42. }
  43. default:
  44. {
  45. cout<<"Invalid input"<<endl;
  46. type=0;
  47. break;
  48. }
  49. }
  50. }
  51.  
  52. string line;
  53. getline(furniture, line);
  54. stringstream ss(line);
  55. ss>>type>>name>>number>>material>>colour>>mattress;
Add Comment
Please, Sign In to add comment