Esempio n. 1
0
        public string GetTicketInfo(int id, Passenger[] passengers, Flight[] flights, string ticketID)
        {
            if (id == this.id)
            {
                for (int i = 0; i < tickets.Count; i++)
                {
                    if (((Ticket)tickets[i]).ticketFound(ticketID))
                    {
                        return ((Ticket)tickets[i]).getInfo(passengers, flights, ticketID);
                    }
                }
            }

            return "Ticket not found!\n";
        }
Esempio n. 2
0
        public virtual string GetTicketInfo(int id, Passenger[] passengers, Flight[] flights)
        {
            string txt = "";

            if (id == this.id)
            {
                for (int i = 0; i < tickets.Count; i++)
                {
                    if (txt != "") txt += "\n";

                    txt += ((Ticket)tickets[i]).getInfo(passengers, flights);

                    txt += "\nTicket type: Economy";
                    txt += "\nLuggage limit: " + luggageWeight + " [kg]";
                    txt += "\n ----------- ";
                }
            }

            return txt;
        }
Esempio n. 3
0
        public Ticket(int passengerID, Flight flight, string ticketID, float price)
        {
            this.passengerID = passengerID;
            this.flight = flight;
            this.price = price;
            this.ticketID = ticketID;

            int[] date = flight.getFlightDate();

            DateTime dt = new DateTime(date[2], date[1], date[0]);
            if (dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday)
            {
                extraTax = 0.07f;
            }
            else
            {
                extraTax = 0.05f;
            }
        }
Esempio n. 4
0
        public string getInfo(Passenger[] passangers, Flight[] flights, string ticketID)
        {
            string text = "";

            if (ticketID == this.ticketID)
            {
                for (int i = 0; i < passangers.Length; i++)
                {
                    if (((Passenger)passangers[i]).customerFound(passengerID))
                    {
                        text += "Ticket ID : " + this.ticketID + "\n";
                        text += (((Passenger)passangers[i]).GetInfo(passengerID)) + "\n";
                    }
                }

                for (int i = 0; i < flights.Length; i++)
                {
                    if (((Flight)flights[i]).flightFound(flight.getFlightID()))
                    {
                        text += (((Flight)flights[i]).getFlightInfo(flight.getFlightID()));
                    }
                }

                float price = getPrice(ticketID);
                if (price != -1)
                    text += "\nPrice: " + price + " Euro";
            }

            return text;
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            int idPessenger = 0;

            Flight[] flights = new Flight[5];
            flights[0] = new Flight("Paris", "Kopenhaga", 1, 5, 2014, "SL321");
            flights[1] = new Flight("Tokyo", "Osaka", 3, 6, 2014, "JA451");
            flights[2] = new Flight("Osaka", "Barcelona", 4, 6, 2014, "EA551");
            flights[3] = new Flight("Rome", "Warsaw", 21, 7, 2014, "WR767");
            flights[4] = new Flight("Warsaw", "Tokyo", 17, 5, 2014, "LOT333");

            Console.WriteLine("Flights List: ");
            Console.WriteLine(flights[0].getFlightInfo("SL321"));
            Console.WriteLine(flights[1].getFlightInfo("JA451"));
            Console.WriteLine(flights[2].getFlightInfo("EA551"));
            Console.WriteLine(flights[3].getFlightInfo("WR767"));
            Console.WriteLine(flights[4].getFlightInfo("LOT333"));
            Console.WriteLine();

            EconomyPassenger[] economyPassengers = new EconomyPassenger [3];
            FirstClassPassenger[] firstClassPassengers = new FirstClassPassenger[3];

            Hashtable passengers = new Hashtable();

            economyPassengers[0] = new EconomyPassenger(idPessenger, "Lionel", "Messi", "+54 444312663", flights[0], "00001"); // ID = 0
            passengers.Add(idPessenger, "EP");
            idPessenger++;

            firstClassPassengers[0] = new FirstClassPassenger(idPessenger, "Yagami", "Akira", "+321 433533222"); // ID = 1
            passengers.Add(idPessenger, "FCP");
            idPessenger++;

            firstClassPassengers[1] = new FirstClassPassenger(idPessenger, "Andrzej", "Kowalski", "+48 723277322", flights[0], "00002"); // ID = 2
            passengers.Add(idPessenger, "FCP");
            idPessenger++;

            firstClassPassengers[1].AddNewTicket(2, flights[1], "00003", 800.0f);
            firstClassPassengers[1].AddNewTicket(2, flights[2], "00004", 1200.0f);

            firstClassPassengers[2] = new FirstClassPassenger(idPessenger, "Jackie", "Chan", "+532 43223444", flights[2], "00005", 32000.0f, 62, "vegetarian dishes"); // ID = 3
            passengers.Add(idPessenger, "FCP");
            idPessenger++;

            economyPassengers[1] = new EconomyPassenger(idPessenger, "Yuna", "Kim", "+442 677727722", flights[1], "00006", 500.0f, 48); // ID = 4
            passengers.Add(idPessenger, "EP");
            idPessenger++;

            economyPassengers[1].AddNewTicket(4, flights[3], "00007", 700.0f);

            economyPassengers[2] = new EconomyPassenger(idPessenger, "Tomasz", "Dziuba", "+48 723333333", flights[4], "00008", 400.0f); // ID = 5
            passengers.Add(idPessenger, "EP");
            idPessenger++;

            economyPassengers[2].AddNewTicket(5, flights[1], "00009", 300.0f);
            economyPassengers[2].AddNewTicket(5, flights[2], "00010", 600.0f);

            Console.WriteLine("Passengers List: ");

            string txt = "";
            IDictionaryEnumerator en = passengers.GetEnumerator();
            while (en.MoveNext())
            {
                if (en.Value.ToString() == "EP")
                {
                    for (int i = 0; i < economyPassengers.Length; i++)
                        txt += economyPassengers[i].GetInfo((int)en.Key);
                }
                else if (en.Value.ToString() == "FCP")
                {
                    for (int i = 0; i < firstClassPassengers.Length; i++)
                        txt += firstClassPassengers[i].GetInfo((int)en.Key);
                }

                if (txt != "")
                {
                    Console.WriteLine(txt);
                    txt = "";
                }
            }
            Console.WriteLine();

            Console.WriteLine("Check Ticket ID: 00001");
            Console.WriteLine(" ----------- ");
            Console.WriteLine(economyPassengers[0].GetTicketInfo(0, economyPassengers, flights, "00001"));
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Tickets List: ");
            Console.WriteLine(" ----------- ");

            en.Reset();
            while (en.MoveNext())
            {
                if (en.Value.ToString() == "EP")
                {
                    for (int i = 0; i < economyPassengers.Length; i++)
                        txt += economyPassengers[i].GetTicketInfo((int)en.Key, economyPassengers, flights);
                }
                else if (en.Value.ToString() == "FCP")
                {
                    for (int i = 0; i < firstClassPassengers.Length; i++)
                        txt += firstClassPassengers[i].GetTicketInfo((int)en.Key, firstClassPassengers, flights);
                }

                if (txt != "")
                {
                    Console.WriteLine(txt);
                    txt = "";
                }
            }

            Console.ReadLine();
        }
Esempio n. 6
0
 public EconomyPassenger(int id, string firstName, string lastName, string phoneNumber, Flight flight, string ticketID, float price, int luggageWeight)
     : base(id, firstName, lastName, phoneNumber, flight, ticketID, price)
 {
     this.luggageWeight = luggageWeight;
 }
Esempio n. 7
0
        public Passenger(int id, string firstName, string lastName, string phoneNumber, Flight flight, string ticketID, float price)
        {
            this.id = id;
            this.firstName = firstName;
            this.lastName = lastName;
            this.phoneNumber = phoneNumber;

            AddNewTicket(id, flight, ticketID, price);
        }
Esempio n. 8
0
 public virtual void AddNewTicket(int pessengerID, Flight flight, string ticketID, float price)
 {
     tickets.Add(new Ticket(id, flight, ticketID, price));
 }
Esempio n. 9
0
 public EconomyPassenger(int id, string firstName, string lastName, string phoneNumber, Flight flight, string ticketID)
     : base(id, firstName, lastName, phoneNumber, flight, ticketID)
 {
     this.luggageWeight = 24;
 }
Esempio n. 10
0
        public override string GetTicketInfo(int id, Passenger[] passengers, Flight[] flights)
        {
            string txt = "";

            if (id == this.id)
            {
                for (int i = 0; i < tickets.Count; i++)
                {
                    if (txt != "") txt += "\n";

                    txt += ((Ticket)tickets[i]).getInfo(passengers, flights);

                    txt += "\nTicket type: First Class";
                    txt += "\nLuggage limit: " + luggageWeight + " [kg]";
                    txt += "\nMeal menu: " + mealMenu;
                    txt += "\n ----------- ";
                }
            }

            return txt;
        }
Esempio n. 11
0
 public override void AddNewTicket(int pessengerID, Flight flight, string ticketID, float price)
 {
     tickets.Add(new Ticket(id, flight, ticketID, price - price*bonus));
     bonus += 0.02f;
 }
Esempio n. 12
0
 public FirstClassPassenger(int id, string firstName, string lastName, string phoneNumber, Flight flight, string ticketID, float price, int luggageWeight, string mealMenu)
     : base(id, firstName, lastName, phoneNumber, flight, ticketID, price, luggageWeight)
 {
     this.mealMenu = mealMenu;
 }
Esempio n. 13
0
 public FirstClassPassenger(int id, string firstName, string lastName, string phoneNumber, Flight flight, string ticketID, int luggageWeight)
     : base(id, firstName, lastName, phoneNumber, flight, ticketID, luggageWeight)
 {
     this.mealMenu = "specials of the day";
 }