Created
May 10, 2017 11:34
-
-
Save varqasim/383da5bf4b77f0dfdafc970680a941a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using RandomNameGeneratorLibrary; | |
namespace VDBCore | |
{ | |
public class Flight | |
{ | |
private string id; | |
public string Id | |
{ | |
get { return id; } | |
set { id = value; } | |
} | |
public enum FlightStatus | |
{ | |
Arriving, | |
Departing | |
} | |
private string flightNumber; | |
private Gate.GateNumberEnum gate; | |
private FlightStatus status; | |
private List<Passenger> passengers; | |
private List<Baggage> baggage; | |
private DateTime scheduledAt; | |
private int passengerCount; | |
private int numberOfBaggage; | |
private int numberOfSuspiciousBaggage; | |
/// <summary> | |
/// Flights constructor | |
/// </summary> | |
/// <param name="flightNumber"></param> | |
/// <param name="passengerCount"></param> | |
/// <param name="gate"></param> | |
/// <param name="status"></param> | |
/// <param name="scheduledAt"></param> | |
/// <param name="numberOfBaggage"></param> | |
public Flight(string flightNumber, int passengerCount, | |
Gate.GateNumberEnum gate, FlightStatus status, DateTime scheduledAt, int numberOfBaggage, | |
int numberOfSuspiciousBaggage) | |
{ | |
this.id = Guid.NewGuid().ToString(); | |
this.passengerCount = passengerCount; | |
this.flightNumber = flightNumber; | |
this.gate = gate; | |
this.status = status; | |
this.scheduledAt = scheduledAt; | |
this.numberOfBaggage = numberOfBaggage; | |
this.numberOfSuspiciousBaggage = numberOfSuspiciousBaggage; | |
this.passengers = new List<Passenger>(); | |
this.baggage = new List<Baggage>(); | |
} | |
/// <summary> | |
/// Remove a passenger baggage from flight | |
/// </summary> | |
/// <param name="passenger"></param> | |
public void RemovePassengerBaggage(Passenger passenger) | |
{ | |
List<Baggage> baggage = this.baggage.FindAll(x => x.Passenger == passenger); | |
foreach (Baggage b in baggage) | |
{ | |
this.baggage.Remove(b); | |
} | |
} | |
/// <summary> | |
/// Get total number of baggages for all passengers of the flights | |
/// </summary> | |
/// <returns></returns> | |
public int GetTotalBaggageCount() | |
{ | |
int total = 0; | |
foreach (Passenger passenger in Passengers) | |
{ | |
total = total + passenger.Baggage.Count; | |
} | |
return total; | |
} | |
public override string ToString() | |
{ | |
return string.Format("Flights {0} - {1} at {2}", this.FlightNumber, this.status.ToString(), this.scheduledAt); | |
} | |
public string FlightNumber | |
{ | |
get { return flightNumber; } | |
set { flightNumber = value; } | |
} | |
public List<Passenger> Passengers | |
{ | |
get { return passengers; } | |
set { passengers = value; } | |
} | |
public int PassengerCount | |
{ | |
get { return passengerCount; } | |
set { passengerCount = value; } | |
} | |
public List<Baggage> Baggage | |
{ | |
get { return baggage; } | |
set { baggage = value; } | |
} | |
public Gate.GateNumberEnum Gate | |
{ | |
get { return gate; } | |
set { gate = value; } | |
} | |
public FlightStatus Status | |
{ | |
get { return status; } | |
set { status = value; } | |
} | |
public DateTime ScheduledAt | |
{ | |
get { return scheduledAt; } | |
set { scheduledAt = value; } | |
} | |
public int NumberOfBaggage | |
{ | |
get { return numberOfBaggage; } | |
set { numberOfBaggage = value; } | |
} | |
public int NumberOfSuspiciousBaggage | |
{ | |
get { return numberOfSuspiciousBaggage; } | |
set { numberOfSuspiciousBaggage = value; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment