Advertisement
pgiovanni

Untitled

Oct 15th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. void Route::populate_piece(string path_to_piece) {
  2.     cout << "Enter the route your piece is on." << endl;
  3.    
  4.     ifstream route_of_piece;
  5.     route_of_piece.open(path_to_piece);
  6.     string stop;
  7.     vector<string> full_route_of_piece;
  8.    
  9.     while (route_of_piece.good()) {
  10.        
  11.         getline(route_of_piece, stop);
  12.         full_route_of_piece.push_back(stop);
  13.     }
  14.  
  15.     string first_stop_on_route;
  16.     string last_stop_on_route;
  17.     cout << "Now enter the first stop you have on this route." << endl;
  18.     getline(cin, first_stop_on_route);
  19.     cout << "now enter the last stop" << endl;
  20.     getline(cin, last_stop_on_route);
  21.     vector<int> range_of_piece;
  22.  
  23.  
  24.     for (unsigned int i = 0; i < full_route_of_piece.size(); ++i) {
  25.  
  26.         if (first_stop_on_route == full_route_of_piece[i])
  27.             range_of_piece.push_back(i);
  28.         if (last_stop_on_route == full_route_of_piece[i])
  29.             range_of_piece.push_back(i);
  30.  
  31.        
  32.    
  33.     }
  34.     for (unsigned int j = 0; j < full_route_of_piece.size(); ++j) {
  35.         if (j >= range_of_piece[0] && j <= range_of_piece[1])
  36.             raw_route_piece.push_back(full_route_of_piece[j]);
  37.  
  38.     }
  39.  
  40.    
  41.    
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement