예제 #1
0
//calculates the duration of a trip given the head flight (which is linked to subsequent flights
long Sort::get_dur(FlightNodeTracker *head)
{
	Date_Time *start_time = get_time(head);
	Date_Time *end;
	long end_time;
	FlightNodeTracker *temp = head;
	//advances to the end
	while(temp->get_next())
	{
		temp = temp->get_next();
	}
	//copies the time
	end = get_time(temp)->copy();
	//moves the time forward
	end->add_min(temp->get_flight()->get_duration());
	// CC: this is a function
	end_time = end->get_min_since_2013();
	delete end;
	//returns the difference
	return end_time - start_time->get_min_since_2013();
}
예제 #2
0
void Route::print_route(int num_bags)
{
	FlightNodeTracker *fl = flight_list;
	cout << "Flight Number\tCompany\t\tSource Location\tDeparture Date/Time" << endl;
	while(fl)
	{
		Date_Time *temp;
		//prints the flight number
		cout << fl->get_flight()->get_flight_num() << "\t\t";
		//prints flight company
		cout << fl->get_flight()->get_flight_comp() << "\t";
		if(strlen(fl->get_flight()->get_flight_comp()) < 8)
		{
			cout <<"\t";
		}
		//prints the source hub's name
		cout << fl->get_flight()->get_source()->get_short_name() << "\t\t";
		//prints the departure time
		cout << fl->get_flight()->get_departure()->get_time() << endl;
		//prints the destination hub's name
		cout << "\t\t\t\t" << fl->get_flight()->get_destination()->get_short_name() << "\t\t";
		//prints the arrival time (without adjusting for time-zones)
		temp = fl->get_flight()->get_departure()->copy();
		temp->add_min(fl->get_flight()->get_duration());

		cout << temp->get_time() << endl;
		//print pricing details
		cout << "\t\t\t\t$" << (fl->get_flight()->get_price() + fl->get_flight()->getBaggageFees(num_bags)) << "\t\t";
		cout << "Base Price: $" << fl->get_flight()->get_price() << endl;

		delete temp;
		//advances the tracker
		fl = fl->get_next();
	}
	cout << "Number of Bags: " << num_bags << endl;
	//prints the price and time
	cout << "Total Price: $" << get_price(num_bags) << endl;
	cout << "Total Time: " << get_time() << " minutes." << endl;
}