Exemplo n.º 1
0
 public AirportController(IAirport airport)
 {
     tripRegistrationNumber = 1;
     this.airport           = airport;
     this.airplaneFactory   = new AirplaneFactory();
     this.itemFactory       = new ItemFactory();
 }
        // Returns null if the runway or the opposite runway cannot be found.
        public static double?GetSlopePercent(this IAirport a, string runway)
        {
            var rwy = a.FindRwy(runway);

            if (rwy == null)
            {
                return(null);
            }

            var oppositeId = RwyIdentConversion.RwyIdentOppositeDir(runway);

            if (oppositeId == null)
            {
                return(null);
            }

            var opposite = a.FindRwy(oppositeId);

            if (opposite == null)
            {
                return(null);
            }

            return((opposite.ElevationFt - rwy.ElevationFt) * 100.0 / rwy.LengthFt);
        }
 public FlightController(IFlight flightService, IAirport airportService, IAirPlane airPlaneService, IFlightHelpersServices flightHelpersServices)
 {
     _airportService        = airportService;
     _airPlaneService       = airPlaneService;
     _flightService         = flightService;
     _flightHelpersServices = flightHelpersServices;
 }
        public AirportController(IAirport airport)
        {
            this.airport = airport;

            this.airplaneFactory = new AirplaneFactory();
            this.itemFactory     = new ItemFactory();
        }
Exemplo n.º 5
0
        public void AddWaypoint(IAirport airport)
        {
            var wps = this.Waypoints.ToList();

            wps.Add(airport);
            this.Waypoints = wps;
        }
Exemplo n.º 6
0
        public static double Distance(IAirport a1, IAirport a2)
        {
            double x        = a1.GetCoordinates().X - a2.GetCoordinates().X;
            double y        = a1.GetCoordinates().Y - a2.GetCoordinates().Y;
            double distance = Math.Sqrt(x * x + y * y);

            return(distance);
        }
Exemplo n.º 7
0
 public AirportController(IAirport airport)
 {
     this.airport          = airport;
     this.airplaneFactory  = new AirplaneFactory();
     this.itemFactory      = new ItemFactory();
     this.passengerFactory = new PassengerFactory();
     this.tripFactory      = new TripFactory();
 }
 public void Setup()
 {
     airport     = new Airport();
     airplane    = new LightAirplane();
     fController = new FlightController(airport);
     trip        = new Trip("Sofia", "Vidin", airplane);
     airport.AddTrip(trip);
 }
Exemplo n.º 9
0
        public AirportStatus ConvertAirport(IAirport airport)
        {
            IEnumerable <Station> stations = airport.GetStations();
            string       name   = airport.Name;
            string       url    = airport.ImageUrl;
            List <Route> routes = airport.Routes;

            return(new AirportStatus(stations, name, url, routes));
        }
Exemplo n.º 10
0
 private List <ITicket> SoldTickets; // prodate karte,kad im dodelimo kupca
 /***************************************/
 //Constructor:
 public Flight(int id, IAirport src, IAirport dst, IPlane plane, double PricePerUnit_)
 {
     Unique_ID    = id;
     SrcAirport   = src;
     DestAirport  = dst;
     Plane        = plane;
     PricePerUnit = PricePerUnit_;
     NewTickets   = new List <ITicket>();
     SoldTickets  = new List <ITicket>();
 }
Exemplo n.º 11
0
 private static void AssertVhhh(IAirport vhhh)
 {
     Assert.IsTrue("VHHH" == vhhh.Icao);
     Assert.IsTrue("Chek Lap Kok International Airport" == vhhh.Name);
     Assert.AreEqual(22.3089008331, vhhh.Lat, delta);
     Assert.AreEqual(113.915000916, vhhh.Lon, delta);
     Assert.AreEqual(28, vhhh.Elevation);
     Assert.AreEqual(false, vhhh.TransAvail);
     Assert.AreEqual(12467, vhhh.LongestRwyLengthFt);
 }
Exemplo n.º 12
0
        /// <summary>This method will create all airports, cargo, and the relationships there of. It will set the starting airport</summary>
        private void Setup()
        {
            //NOTE Create Airports
            Airport boi = new Airport("boi", "Boise Airport");
            Airport pdx = new Airport("pdx", "Portland Airport");
            Airport ord = new Airport("ord", "Chicago O'Hare Airport");
            Airport den = new Airport("den", "Denver Airport");
            Airport oak = new Airport("oak", "Oakland Airport");
            Airport yyz = new Airport("yyz", "Toronto Airport");
            Airport hnl = new Airport("hnl", "Honolulu Airport");

            //NOTE Create relationships between
            boi.AddConnection(pdx);
            pdx.AddConnection(boi);

            boi.AddConnection(den);
            den.AddConnection(boi);

            pdx.AddConnection(den);
            den.AddConnection(pdx);

            pdx.AddConnection(oak);
            oak.AddConnection(pdx);

            pdx.AddConnection(hnl);
            hnl.AddConnection(pdx);

            ord.AddConnection(yyz);
            yyz.AddConnection(ord);

            ord.AddConnection(den);
            den.AddConnection(ord);

            //NOTE Create Packages
            Package p1 = new Package(boi, 100);
            Package p2 = new Package(pdx, 125);
            Package p3 = new Package(ord, 250);
            Package p4 = new Package(den, 50);
            Package p5 = new Package(oak, 300);
            Package p6 = new Package(yyz, 310);
            Package p7 = new Package(hnl, 5);

            //NOTE Add pacakges to Airports
            hnl.Pickups.Add(p1);
            yyz.Pickups.Add(p2);
            oak.Pickups.Add(p3);
            oak.Pickups.Add(p4);
            ord.Pickups.Add(p5);
            pdx.Pickups.Add(p6);
            boi.Pickups.Add(p7);

            //NOTE Set your starting point, this creates access to the web of connections that was made
            CurrentAirport = boi;
        }
Exemplo n.º 13
0
        public static bool Connected(IAirport a1, IAirport a2)
        {
            bool connected = false;

            foreach (IAirport airport in a1.GetAirports())
            {
                if (airport == a2)
                {
                    connected = true; break;
                }
            }
            return(connected);
        }
Exemplo n.º 14
0
        public List <IFlight> FindByDestAirport(IAirport dest)
        {
            List <IFlight> flights_to_return = new List <IFlight>();

            foreach (Flight flight in Flights)
            {
                if (flight.GetDestAirport() == dest)
                {
                    flights_to_return.Add(flight);
                }
            }
            return(flights_to_return);
        }
Exemplo n.º 15
0
        public List <IFlight> FindBySrcAirport(IAirport src)
        {
            List <IFlight> flights_to_return = new List <IFlight>();

            foreach (Flight flight in Flights)
            {
                if (flight.GetSrcAirport() == src)
                {
                    flights_to_return.Add(flight);
                }
            }
            return(flights_to_return);
        }
Exemplo n.º 16
0
 public static bool Equals(IAirport x, IAirport y)
 {
     return(x != null &&
            y != null &&
            x.Icao == y.Icao &&
            x.Name == y.Name &&
            x.Lat == y.Lat &&
            x.Lon == y.Lon &&
            x.Elevation == y.Elevation &&
            x.TransAvail == y.TransAvail &&
            x.TransAlt == y.TransAlt &&
            x.TransLvl == y.TransLvl &&
            x.LongestRwyLengthFt == y.LongestRwyLengthFt &&
            x.Rwys.SetEquals(y.Rwys));
 }
Exemplo n.º 17
0
        private static void AssertVhhhRwys(IAirport vhhh)
        {
            var rwys = vhhh.Rwys;

            var _7L = rwys.Where(r => r.RwyIdent == "07L").First();

            Assert.IsTrue(_7L.Heading == "74");
            Assert.AreEqual(12467, _7L.LengthFt);
            Assert.AreEqual(197, _7L.WidthFt);
            Assert.AreEqual(false, _7L.HasIlsInfo);
            Assert.AreEqual(22.3104, _7L.Lat, delta);
            Assert.AreEqual(113.896, _7L.Lon, delta);
            Assert.AreEqual(22, _7L.ElevationFt);
            Assert.IsTrue("ASP" == _7L.SurfaceType);

            var _7R = rwys.Where(r => r.RwyIdent == "07R").First();

            Assert.IsTrue(_7R.Heading == "74");
            Assert.AreEqual(12467, _7R.LengthFt);
            Assert.AreEqual(197, _7R.WidthFt);
            Assert.AreEqual(false, _7R.HasIlsInfo);
            Assert.AreEqual(22.2962, _7R.Lat, delta);
            Assert.AreEqual(113.898, _7R.Lon, delta);
            Assert.AreEqual(28, _7R.ElevationFt);
            Assert.IsTrue("ASP" == _7R.SurfaceType);

            var _25R = rwys.Where(r => r.RwyIdent == "25R").First();

            Assert.IsTrue(_25R.Heading == "254");
            Assert.AreEqual(12467, _25R.LengthFt);
            Assert.AreEqual(197, _25R.WidthFt);
            Assert.AreEqual(false, _25R.HasIlsInfo);
            Assert.AreEqual(22.3216, _25R.Lat, delta);
            Assert.AreEqual(113.931, _25R.Lon, delta);
            Assert.AreEqual(23, _25R.ElevationFt);
            Assert.IsTrue("ASP" == _25R.SurfaceType);

            var _25L = rwys.Where(r => r.RwyIdent == "25L").First();

            Assert.IsTrue(_25L.Heading == "254");
            Assert.AreEqual(12467, _25L.LengthFt);
            Assert.AreEqual(197, _25L.WidthFt);
            Assert.AreEqual(false, _25L.HasIlsInfo);
            Assert.AreEqual(22.3074, _25L.Lat, delta);
            Assert.AreEqual(113.933, _25L.Lon, delta);
            Assert.AreEqual(27, _25L.ElevationFt);
            Assert.IsTrue("ASP" == _25L.SurfaceType);
        }
 public static IAirport ToAirport(this IAirport airport)
 {
     return(new Airport
     {
         Iata = airport.Iata,
         Icao = airport.Icao,
         Elevation = airport.Elevation,
         Latitude = airport.Latitude,
         Longitude = airport.Longitude,
         Name = airport.Name,
         City = airport.City,
         State = airport.State,
         Country = airport.Country,
         Timezone = airport.Timezone,
     });
 }
Exemplo n.º 19
0
        public List <IFlight> GetFlightsTo(IAirport dest)
        {
            //AllFlights sadrzi sve letove u bazi podataka,
            //i ispitujemo svaki let da li ima IAirport dest kao svoj odredisni aerodrom
            IFlightDatabase database      = FlightDatabase.Instance;
            List <IFlight>  AllFlights    = database.GetFlightsList();
            List <IFlight>  FlightsToDest = new List <IFlight>();

            foreach (IFlight flight in AllFlights)
            {
                if ((flight.GetSrcAirport() == this) && (flight.GetDestAirport() == dest))
                {
                    FlightsToDest.Add(flight);
                }
            }
            return(FlightsToDest);
        }
Exemplo n.º 20
0
        public Presenter(IView view)
        {
            _view    = view;
            _airport = AirportDB.Create();

            _view.DisplayFlightEventRaise          += OnDisplayFlightEventRaise;
            _view.SearchFlightByNumberEventRaise   += OnSearchFlightByNumberEventRaise;
            _view.SearchFlightByDateTimeEventRaise += OnSearchFlightByDateTimeEventRaise;
            _view.SearchFlightByCityEventRaise     += OnSearchFlightByCityEventRaise;
            _view.SearchFlightEventRaise           += OnSearchFlightEventRaise;
            _view.DeleteFlightEventRaise           += OnDeleteFlightEventRaise;
            _view.AddFlightEventRaise                 += OnAddFlightEventRaise;
            _view.EditFlightEventRaise                += OnEditFlightEventRaise;
            _view.ReturnEditedFlightEventRaise        += OnReturnEditedFlightEventRaise;
            _view.EditePassengerEventRaise            += OnEditePassengerEventRaise;
            _view.AddPassangerEventRaise              += OnAddPassangerEventRaise;
            _view.SearchPassengerByFlightEventRaise   += OnSearchPassengerEventRaise;
            _view.SearchPassengerByNameEventRaise     += OnSearchPassengerByNameEventRaise;
            _view.SearchPassengerByPassportEventRaise += OnSearchPassengerByPassportEventRaise;
            _view.DeletePassengerEventRaise           += OnDeletePassengerEventRaise;
        }
Exemplo n.º 21
0
        public virtual void AssignPlaneMakers()
        {
            IAirport benGurion = this.airportManager.GetAirport("Ben Gurion");

            benGurion.ChangeInState += RaiseChangeInStateEvent;
            IAirport ovda = this.airportManager.GetAirport("Ovda");

            ovda.ChangeInState += RaiseChangeInStateEvent;

            IdManager.Id = dalService.GetIdCount();

            IPlaneMaker planeMaker = new PlaneMaker(benGurion);

            planeMaker.ConfigureTimer(TimeSpan.FromSeconds(15));
            planeMaker.StartTimer();

            IPlaneMaker ovdaPlaneMaker = new OvdaPlaneMaker(ovda, ovda.Routes.ToArray());

            ovdaPlaneMaker.ConfigureTimer(TimeSpan.FromSeconds(25));
            ovdaPlaneMaker.StartTimer();
        }
Exemplo n.º 22
0
        public void InsertFlight(IFlight f)
        {
            if (f == null)
            {
                return;
            }

            //Ako izvorisni i odredisni aerodromi leta nisu povezani baca se izuzetak
            if (!IAirport.Connected(f.GetDestAirport(), f.GetSrcAirport()))
            {
                throw new AirportsNotConnectedException("Aerodromi nisu povezani");
            }

            //proveravamo da li u listi letova postoji vec let sa istim identifikacionim brojem
            foreach (IFlight flight in Flights)
            {
                if (flight.GetUnique_ID() == f.GetUnique_ID())
                {
                    throw new IdConflictException("Vec postoji let sa zadatim identifikacionim brojem");
                }
            }
            Flights.Add(f);
        }
Exemplo n.º 23
0
 public Package(IAirport destination, int reward)
 {
     Destination = destination;
     Reward      = reward;
 }
Exemplo n.º 24
0
        public FlightController(IAirport airport)
        {
            this.airport = airport;

            this.randomGenerator = new Random(EjectionSeed);
        }
Exemplo n.º 25
0
 public AirportController(IAirport airportService)
 {
     _airportService = airportService;
 }
Exemplo n.º 26
0
 public FlightController(IAirport airport)
 {
     this.airport         = airport;
     this.randomGenerator = new Random(EJECTION_SEED);
 }
Exemplo n.º 27
0
        public IFlight CreateFlight(int id, IAirport src, IAirport dst, IPlane plane, double pricePerUnit)
        {
            IFlight f = new Flight(id, src, dst, plane, pricePerUnit);

            return(f);
        }
Exemplo n.º 28
0
 public void AddWaypoint(IAirport airport)
 {
     var wps = this.Waypoints.ToList();
     wps.Add(airport);
     this.Waypoints = wps;
 }
Exemplo n.º 29
0
 public static void Connect(IAirport a1, IAirport a2) //povezujemo dva aerodroma tako sto ih dodamo medjusobno
 {                                                    //u listu njihovih povezanih aerodroma
     a1.GetAirports().Add(a2);
     a2.GetAirports().Add(a1);
 }
 public AirportController(IAirport airport, IAirplaneFactory airplaneFactory, IItemFactory itemFactory)
 {
     this.airport         = airport;
     this.airplaneFactory = airplaneFactory;
     this.itemFactory     = itemFactory;
 }
Exemplo n.º 31
0
 public void AddAirport(IAirport airport)
 {
     this.airports.Add(airport);
 }