public void save(object sender, EventArgs e)
        {
            AirlineEmployee airlineEmployee = new AirlineEmployee(controls[0].Text.ToString(), controls[1].Text.ToString(), ((Airline)(((ComboBox)controls[2]).SelectedItem)));

            Population.Instance.airlineEmployees.Add(airlineEmployee);
            Population.Instance.airlines[Population.Instance.airlines.IndexOf(airlineEmployee.airline)].AddAirlineEmployee(airlineEmployee);
            ((Form)((Button)sender).Parent).Close();
        }
        public void save(object sender, EventArgs e)
        {
            AirlineEmployee oldticket = AirlineEmployee.Copy((AirlineEmployee)o);

            oldObject = oldticket;
            ((AirlineEmployee)o).firstName = controls[0].Text;
            ((AirlineEmployee)o).lastName  = controls[1].Text;
            ((AirlineEmployee)o).airline   = (Airline)(((ComboBox)(controls[2])).SelectedItem);
            ((Form)((Button)sender).Parent).Close();
        }
Пример #3
0
        public Command(object oldObject, object newObject, Receiver receiver)
        {
            string oldObjectTypeName = oldObject.GetType().Name;
            string newObjectTypeName = newObject.GetType().Name;

            //check the class of the object
            if (oldObjectTypeName == "Airline")
            {
                // take a copy of the object before and after being updated
                this.oldObject = Airline.Copy((Airline)oldObject);
                this.newObject = Airline.Copy((Airline)newObject);
            }
            else if (oldObjectTypeName == "AirlineEmployee")
            {
                this.oldObject = AirlineEmployee.Copy((AirlineEmployee)oldObject);
                this.newObject = AirlineEmployee.Copy((AirlineEmployee)newObject);
            }
            else if (oldObjectTypeName == "Airplane")
            {
                this.oldObject = Airplane.Copy((Airplane)oldObject);
                this.newObject = Airplane.Copy((Airplane)newObject);
            }
            else if (oldObjectTypeName == "Airport")
            {
                this.oldObject = Airport.Copy((Airport)oldObject);
                this.newObject = Airport.Copy((Airport)newObject);
            }
            else if (oldObjectTypeName == "BookingAgent")
            {
                this.oldObject = BookingAgent.Copy((BookingAgent)oldObject);
                this.newObject = BookingAgent.Copy((BookingAgent)newObject);
            }
            else if (oldObjectTypeName == "Customer")
            {
                this.oldObject = Customer.Copy((Customer)oldObject);
                this.newObject = Customer.Copy((Customer)newObject);
            }
            else if (oldObjectTypeName == "Flight")
            {
                this.oldObject = Flight.Copy((Flight)oldObject);
                this.newObject = Flight.Copy((Flight)newObject);
            }
            else if (oldObjectTypeName == "Ticket")
            {
                this.oldObject = Ticket.Copy((Ticket)oldObject);
                this.newObject = Ticket.Copy((Ticket)newObject);
            }


            this.receiver = receiver;
        }
        /// <summary>
        /// Passenger Factory method.
        /// Initializes instance of Passenger Class.
        /// </summary>
        /// <param name="passengerId"></param>
        /// <param name="isUsingLoyalty"></param>
        /// <param name="LoyaltyPoints"></param>
        /// <param name="hasExtraBags"></param>
        /// <returns></returns>
        private static IPassengerDetails GetPassengerType(string passengerId, bool isUsingLoyalty, int LoyaltyPoints, bool hasExtraBags)
        {
            IPassengerDetails passenger;

            switch (passengerId)
            {
            case "airline":
                passenger = new AirlineEmployee(new FlightSummaryValidator());
                break;

            case "general":
                passenger = new GeneralPassenger(new FlightSummaryValidator());
                break;

            case "loyalty":
                passenger = new LoyaltyMember(new LoyaltyBenefits(isUsingLoyalty, LoyaltyPoints, hasExtraBags), new FlightSummaryValidator());
                break;

            default: throw new Exception();
            }
            return(passenger);
        }
Пример #5
0
        public void Setup()
        {
            _iPassengerDetails = Substitute.For <IPassengerDetails>();

            _airlineEmployee = new AirlineEmployee(new FlightSummaryValidator());
        }
        public void CreatePopulation()
        {
            #region customer
            Customer ahmad = new Customer("Ahmet Baaj", "*****@*****.**", "0535417086", "A905123", new DateTime(2018, 01, 01), "Syria", new DateTime(2005, 10, 13));
            Customer zaina = new Customer("Zaina Baaj", "*****@*****.**", "0535417085", "A905122", new DateTime(2018, 01, 01), "Syria", new DateTime(1995, 10, 13));
            customers = new List <Customer>();
            customers.Add(ahmad);
            customers.Add(zaina);
            #endregion

            #region booking agent
            BookingAgent yalovatravel = new BookingAgent("Yalova Travel Agency");
            BookingAgent bursatravel  = new BookingAgent("Bursa Travel Agency");
            bookingagents = new List <BookingAgent>();
            bookingagents.Add(yalovatravel);
            bookingagents.Add(bursatravel);
            #endregion



            #region airline
            airlines = new List <Airline>();
            Airline THY        = new Airline("THY");
            Airline Pegasus    = new Airline("Pegasus");
            Airline Sunexpress = new Airline("Sun Express");
            airlines.Add(THY);
            airlines.Add(Pegasus);
            airlines.Add(Sunexpress);
            airlines.Remove(Pegasus);
            airlines.Add(Pegasus);
            #endregion
            #region airplanes
            airplanes = new List <Airplane>();
            Airplane thy_boeing01        = new Airplane(270, airlines[0]);
            Airplane sunexpress_boeing01 = new Airplane(270, airlines[2]);
            airplanes.Add(thy_boeing01);
            airplanes.Add(sunexpress_boeing01);
            //binding the airplane with its airline
            thy_boeing01.airline.AddAirplane(thy_boeing01);
            sunexpress_boeing01.airline.AddAirplane(sunexpress_boeing01);
            #endregion
            #region airline employee
            airlineEmployees = new List <AirlineEmployee>();
            AirlineEmployee leonardo = new AirlineEmployee("Leonardo", "De caprio", airlines[0]);
            AirlineEmployee tom      = new AirlineEmployee("Tom", "Hanks", airlines[2]);
            airlineEmployees.Add(leonardo);
            airlineEmployees.Add(tom);
            //binding airline with employee
            leonardo.airline.AddAirlineEmployee(leonardo);
            tom.airline.AddAirlineEmployee(tom);

            #endregion
            #region airport
            airports = new List <Airport>();
            Airport ataturk = new Airport("Atatürk", "İstanbul");
            Airport sabiha  = new Airport("Sabiha Gökçen", "İstanbul");
            Airport erhac   = new Airport("Erhaç", "Malatya");
            airports.Add(ataturk);
            airports.Add(sabiha);
            airports.Add(erhac);
            #endregion


            #region flights
            flights = new List <Flight>();
            List <Airport> a1 = new List <Airport>();
            a1.Add(ataturk);
            a1.Add(erhac);
            List <Airport> a2 = new List <Airport>();
            a2.Add(ataturk);
            a2.Add(sabiha);
            Flight f1 = new Flight(new DateTime(2017, 06, 06, 06, 00, 00), new DateTime(2017, 06, 06, 08, 00, 00), 150, THY, thy_boeing01, a1);
            Flight f2 = new Flight(new DateTime(2017, 06, 06, 06, 00, 00), new DateTime(2017, 06, 06, 08, 00, 00), 150, Sunexpress, sunexpress_boeing01, a2);
            f1.airline.AddFlight(f1);
            f2.airline.AddFlight(f2);
            f1.airplane.AddFlight(f1);
            f2.airplane.AddFlight(f2);
            //binding airports with flights
            f1.airports[0].AddFlight(f1);
            f1.airports[1].AddFlight(f1);
            f2.airports[0].AddFlight(f2);
            f2.airports[1].AddFlight(f2);


            flights.Add(f1);
            flights.Add(f2);

            #endregion

            #region tickets
            tickets = new List <Ticket>();
            Ticket ahmad_sunexress = new Ticket(ahmad, yalovatravel, f2, Sunexpress);
            // binding the ticket with its airline , flight , booking agent and customer
            ahmad_sunexress.airline.AddTicket(ahmad_sunexress);
            ahmad_sunexress.flight.AddTickets(ahmad_sunexress);
            ahmad_sunexress.bookingAgent.Addticket(ahmad_sunexress);
            ahmad_sunexress.customer.AddTicket(ahmad_sunexress);
            tickets.Add(ahmad_sunexress);
            #endregion
        }
Пример #7
0
        public override void Display()
        {
            base.Display();

            string command;

            do
            {
                System.Console.WriteLine("Please enter command.");
                command = System.Console.ReadLine() ?? "";

                try
                {
                    var enteredText = command.ToLower();
                    if (enteredText.Contains("add general"))
                    {
                        var passengerSegments = enteredText.Split(' ');
                        var generalPassenger  = new GeneralPassenger
                        {
                            Name = passengerSegments[2],
                            Age  = Convert.ToInt32(passengerSegments[3])
                        };
                        FlightProgram.ScheduledFlight.AddPassenger(generalPassenger);
                    }
                    else if (enteredText.Contains("add loyalty"))
                    {
                        var passengerSegments = enteredText.Split(' ');
                        var loyaltyPassenger  = new LoyaltyPassenger
                        {
                            Name        = passengerSegments[2],
                            Age         = Convert.ToInt32(passengerSegments[3]),
                            TotalPoints = Convert.ToInt32(passengerSegments[4]),
                            UsePoints   = Convert.ToBoolean(passengerSegments[5])
                        };
                        FlightProgram.ScheduledFlight.AddPassenger(loyaltyPassenger);
                    }
                    else if (enteredText.Contains("add airline"))
                    {
                        var passengerSegments = enteredText.Split(' ');
                        var airlineEmployee   = new AirlineEmployee
                        {
                            Name = passengerSegments[2],
                            Age  = Convert.ToInt32(passengerSegments[3])
                        };
                        FlightProgram.ScheduledFlight.AddPassenger(airlineEmployee);
                    }
                    else if (enteredText.Contains("add discount"))
                    {
                        var passengerSegments = enteredText.Split(' ');
                        var discountEmployee  = new DiscountedPassenger
                        {
                            Name = passengerSegments[2],
                            Age  = Convert.ToInt32(passengerSegments[3])
                        };
                        FlightProgram.ScheduledFlight.AddPassenger(discountEmployee);
                    }
                    else if (enteredText.Contains("display summary"))
                    {
                        Program.NavigateTo <DisplaySummaryPage>();
                    }
                }
                catch
                {
                    Output.WriteLine("Input format was not in a correct format. Please try again.");
                }
            } while (command != "exit");

            Input.ReadString("Press [Enter] to navigate home");
            Program.NavigateHome();
        }