Example #1
0
int PQR(map &a_map, dijkstra &a_D) {
	string a;
	int b, c;
	vector<bus>::difference_type townSize;
	townSize = a_map.getTown()->size() - 1;

	cout << "Please enter the start time:\n";
	a = cinTime();
	cout << "Please enter the departure town number (0.." << townSize << "):\n";
	b = select();
	cout << "Please enter the destination town number (0.." << townSize
			<< "):\n";
	c = select();

	string tmpTrace = a_D.QuickestR(a_map, a, b, c);
	string trace = (char) (b + 48) + tmpTrace;
	if (tmpTrace.empty()) {
		cout << "Journey not possible\n";
		return 1;
	}

	cout << trace << endl;
	a_map.displayTrace(trace, a);
	return 0;
}
Example #2
0
int pDirectBus(map &a_map) {
	cout << "Please enter a town number (0.." << (a_map.getTown()->size() - 1)
			<< "):\n";
	int townIndex = select();
	a_map.print_DBus(townIndex);

	return 0;
}
Example #3
0
int PEAT(map &a_map, dijkstra &a_D) {
	string a;
	int b, c;
	vector<bus>::difference_type townSize;
	townSize = a_map.getTown()->size() - 1;

	cout << "Please enter the start time:\n";
	a = cinTime();
	cout << "Please enter the departure town number (0.." << townSize << "):\n";
	b = select();
	cout << "Please enter the destination town number (0.." << townSize
			<< "):\n";
	c = select();

	cout << a_D.earlyAT(a_map, a, b, c) << endl;

	return 0;
}
Example #4
0
int pNextDB(map &a_map) {
	string depT;
	vector<bus>::difference_type townSize;
	int a, b;
	townSize = a_map.getTown()->size() - 1;

	//Collecting informations
	cout << "Please enter the start time:\n";
	depT = cinTime();
	cout << "Please enter the departure town number (0.." << townSize << "):\n";
	a = select();
	cout << "Please enter the destination town number (0.." << townSize
			<< "):\n";
	b = select();
	a_map.print_NBus(depT, a, b);

	return 0;
}
Example #5
0
int readInFile(string fileName, map &bMap) {
	ifstream readin;
	readin.open(fileName.c_str());

	//Initialize towns name
	int cirTime(0);
	readin >> cirTime;

	for (int i = 0; i < cirTime; ++i) {
		string a;
		readin >> a;
		bMap.newTown(a);
	}

	//insert buses into town
	cirTime = 0;
	readin >> cirTime;
	for (int i = 0; i < cirTime; ++i) {
		int a, b;
		string c, d;
		readin >> a >> b >> c >> d;

		//insert "0" if time string only have three digits
		if (c.length() == 3) {
			c = "0" + c;
		}
		if (d.length() == 3) {
			d = "0" + d;
		}

		bMap.getTown(a)->addBus(b, c, d);
	}
	readin.close();

	return 0;
}