Esempio n. 1
0
        public void EraseBooking(Eticket et)
        {
            Eticket rem = null;

            foreach (Eticket at in flightBookings)
            {
                if (at.Equals(et))
                {
                    if (at.Code[0] == 'E')
                    {
                        bookedEconomyClass--;
                    }
                    else if (at.Code[0] == 'B')
                    {
                        bookedBuisnessClass--;
                    }
                    else
                    {
                        bookedFirstClass--;
                    }
                    rem = at;
                    break;
                }
            }
            if (rem == null)
            {
                return;
            }
            flightBookings.Remove(rem);
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != this.GetType())
            {
                return(false);
            }
            Eticket con = (Eticket)obj;

            return(code.Equals(con.Code));
        }
Esempio n. 3
0
        public bool CancelFlightBooking(string ticketCode)
        {
            Eticket found = null;

            foreach (Eticket et in BookingList)
            {
                if (et.Code == ticketCode)
                {
                    found = et;
                    break;
                }
            }
            if (found == null)
            {
                return(false);
            }
            Flight associatedFlight = (Flight)FileHandler.Find(ObjectChoices.Flight, found.FlightNumber.ToString());

            associatedFlight.EraseBooking(found);
            BookingList.Remove(found);
            FileHandler.Add(ObjectChoices.Flight, associatedFlight);
            return(true);
        }
Esempio n. 4
0
        public bool MakeFlightBooking(int flightNumber, FlightSeatClass seat)
        {
            Flight BookIn = (Flight)FileHandler.Find(ObjectChoices.Flight, flightNumber.ToString());

            if (BookIn == null)
            {
                return(false);               //write response
            }
            if (credit.getBalance() < BookIn.getTeckitPrice(seat))
            {
                return(false);                                                  //
            }
            Eticket et = BookIn.BookSeat(this, seat);

            if (et == null)
            {
                return(false);           //
            }
            credit.Withdraw(BookIn.getTeckitPrice(seat));
            BookingList.Add(et);
            FileHandler.Add(ObjectChoices.Flight, BookIn);
            return(true);
        }
Esempio n. 5
0
        public Eticket BookSeat(Passenger pass, FlightSeatClass type)
        {
            if (DateTime.Now > departueDate)
            {
                FlightState = FlightSatus.Arrived;
            }
            if (FlightState == FlightSatus.Arrived || FlightState == FlightSatus.Canclled)
            {
                return(null);
            }
            char tp = ' ';

            if (type == FlightSeatClass.First && bookedFirstClass < availSeatFirstClass)
            {
                tp = 'F';
                bookedFirstClass++;
            }
            else if (type == FlightSeatClass.Economy && bookedEconomyClass < availSeatEconomyClass)
            {
                tp = 'E';
                bookedEconomyClass++;
            }
            else if (type == FlightSeatClass.Buisness && bookedBuisnessClass < availSeatBuisnessClass)
            {
                tp = 'B';
                bookedBuisnessClass++;
            }
            else
            {
                return(null);
            }
            Eticket et = new Eticket(pass.Name, pass.PassportNumber, flightNumber, getTeckitPrice(type), tp);

            flightBookings.Add(et);
            //Console.WriteLine("Congrats ! Succesfull booking..");
            return(et);
        }