Esempio n. 1
0
// Inserts flight into LinkedList based on string parameters for Flight attributes
void addFlight(string FlightNumber, double price, string departure, int duration, string sourceAirportName, string destinationAirportName, string company) {
	
	FlightNode *newFlightNode;					
	if (company.compare("USAirway") == 0) {
		newFlightNode = new FlightUSAirway();	// Inhertiance
	} else if (company.compare("Delta") == 0) {
		newFlightNode = new FlightDelta();		// Inhertiance 
	} else {
		newFlightNode = new FlightSouthWest();	// Inhertiance 
	}
	

	Date_Time *departureTime = new Date_Time(departure);		// create pointer to date_time class and use the ptr to access the date and time values
	Date_Time *arrivalTime = new Date_Time(departure);
	HubNode* sourceHub = searchHub(sourceAirportName, headHub);  
	HubNode* destinationHub = searchHub(destinationAirportName, headHub);  

	newFlightNode->flightCompany = company;
	newFlightNode->flightNumber = FlightNumber;
	newFlightNode->price = price;
	newFlightNode->departure = departureTime; 
	newFlightNode->departure->AddMinutes(newFlightNode->getDelay());
	newFlightNode->duration = duration;
	newFlightNode->source = sourceHub;
	newFlightNode->destination = destinationHub;
	arrivalTime->AddMinutes(duration + newFlightNode->getDelay());
	newFlightNode->arrival = arrivalTime;

	// Insert new flight node into linked list
	newFlightNode->next = sourceHub->headFlights;
	sourceHub->headFlights = newFlightNode;

};
Esempio n. 2
0
/* Returns the arrival time of flight.  Returns 0 if there are no flights */
Date_Time* FlightPlan::calculateArrivalTime() {
	Date_Time* arrival;

	arrival = startTime;
	arrival->AddMinutes(calculateDuration());

	return arrival;
}
Esempio n. 3
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();
}
Esempio n. 4
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;
}