Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Route.h"
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- Route::Route() {}
- void Route::populate(string path_to_route) {
- ifstream choose_route;
- choose_route.open (path_to_route);
- string stop;
- while (choose_route.good()) {
- getline(choose_route, stop);
- raw_route.push_back(stop);
- }
- choose_route.close();
- }
- void Route::sort_packages() {
- vector<int> package_indexes;
- string one_package_in;
- bool continue_scanning = true;
- do {
- getline(cin, one_package_in);
- if (one_package_in == "stop")
- continue_scanning = false;
- for (unsigned int package_index = 0; package_index < raw_route.size(); ++package_index) {
- if (one_package_in == raw_route[package_index])
- package_indexes.push_back(package_index);
- }
- if (find(raw_route.begin(), raw_route.end(), one_package_in) == raw_route.end() && one_package_in != "stop") {
- cout << "Package not on route, Please check your spelling." << endl;
- }
- } while (continue_scanning);
- sort(package_indexes.begin(), package_indexes.end());
- for (unsigned int i = 0; i < package_indexes.size(); ++i)
- cout << "Stop " + to_string(i) + ": " + raw_route[package_indexes[i]] << endl;
- }
- void Route::time_calculation() {
- string location;
- bool continue_searching = true;
- cout << "Enter your current location" << endl;
- do {
- getline(cin, location);
- for (float i = 0; i < raw_route.size(); ++i) {
- if (location == raw_route[i] && find(raw_route.begin(), raw_route.end(), location) != raw_route.end()) {
- float percent_completed = i / raw_route.size() * 100;
- float percent_left = 100 - (i / raw_route.size()) * 100;
- cout << "You have done " + to_string(percent_completed) +
- "% of the stops on this route. \nYou have " + to_string(percent_left) +
- "% percent of the stops left on the route." << endl;
- continue_searching = false;
- }
- }
- if (find(raw_route.begin(), raw_route.end(), location) == raw_route.end())
- cout << "Invalid entry!" << endl;
- } while (continue_searching);
- }
- void Route::raw_route_piece(string path_to_piece) {
- }
Add Comment
Please, Sign In to add comment