Example #1
0
 public void CancelReservationOnFlightMethod(int flightnum, DateTime deptdate, int passID, int seatnum)
 {
     foreach (Person prsn in TravelAgency.people)
     {
         if (prsn is Passenger)
         {
             Passenger pass = prsn as Passenger;
             if (pass.Id == passID)
             {
                 foreach (ScheduledFlight flight in TravelAgency.scheduledflights)
                 {
                     if (flight.FlightID == flightnum && flight.DepartureDate == deptdate)
                     {
                         flight.CancelReservationFlight(pass, seatnum);
                     }
                     else
                     {
                         TravelAgency.FindFlight(flightnum, deptdate);
                     }
                 }
             }
             else
             {
                 throw new NotFoundException("Passenger Not Found");
             }
         }
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            TravelAgency trava = new TravelAgency();

            trava.ShowDialog();

            //Address ktovet = new Address("kablan", "jerusalem", "israel", "0000");
            //Person adam1 = new Person("Rivky", "Gold", 'f', ktovet, "12345");
            //Person adam2 = new Person("Shira", "Silver", 'f', ktovet, "023456789");
            //TravelAgent joe = new TravelAgent("joe", "bean", 'b', ktovet, "12345", 1, 3.5, "09876",0.1);
            //TravelAgent joe1 = new TravelAgent("joe1", "bean", "011234543", "12345", "Yellow Rd", "Lakewood", "NJ", "1234");
            //CreditCard chase = new CreditCard(1,2,1,1234);
            //Customer cust1 = new Customer("joe", "bean", 'b', ktovet, "12345", 1, chase);
            //Customer cust2 = new Customer("Bina", "Green", "02 345 6789", "Orange Rd", "Je", "NY", "2432");
            //Person cust3 = new Customer("rivky", "hello", 'f', ktovet, "hello", 1, chase);
            //Console.WriteLine(adam1);
            //Console.WriteLine(adam2);
            //Console.WriteLine();
            //Console.WriteLine(cust1);
            //Console.WriteLine();
            //Console.WriteLine(cust2);
            //Console.WriteLine();
            //Console.WriteLine(joe);
            //Console.WriteLine();
            //Console.WriteLine(joe1);
            //Console.WriteLine();
            //Console.WriteLine(cust3);

            //chase.AddCharge(67.6, 3456, DateTime.Now);
            //cust1.ChargeCard(45.6, 4567);
            //joe.BookTicket(7899);

            //Passport darchon = new Passport("frummy", "Braun", "USA", "American");
            //Passport darchon2 = new Passport(1234, "Jack", "Jend", DateTime.Now.ToString(), "India", DateTime.Now.AddYears(2).ToString(),DateTime.Now.AddYears(12).ToString(), "Indian");
            //Passenger pass1 = new Passenger("aby", "Gren", "085 674 786", darchon, ktovet);
            //Passenger pass2 = new Passenger("Gan", "Gold", "0897654321", "Fay", "Jhb", "Gt", "4567", darchon);
            //Seat Kisey = new Seat("economy");

            //Console.WriteLine(darchon);
            //Console.WriteLine(darchon2);
            //darchon2.isExpired();
            //Console.WriteLine();

            //Console.WriteLine(pass1);
            //Console.WriteLine(pass2);
            //pass2.hasPassport();
            //Console.WriteLine();

            //Console.WriteLine(Kisey);
            //Kisey.BookSeat(pass2);
            //Kisey.CancelReservation();
        } //End of main
Example #3
0
 public void BookSeatOnFlightMethod(int flightnum, DateTime dt, int custid, int passengerid, int seatnum, int empid, double price)
 //custid pays for the flight passengerid flighs
 {
     try
     {
         foreach (Person p in TravelAgency.people)
         {
             if (p is Passenger)
             {
                 Passenger ps = p as Passenger;
                 if (ps.Id == passengerid)
                 {
                     foreach (Passenger pas in ScheduledFlight.passengers)
                     {
                         if (pas.Passport == ps.Passport)//if the passenger is already booked with this passport then throw an exception
                         {
                             throw new DuplicateDataExcception("already booked!");
                         }
                     }
                     foreach (ScheduledFlight flight in TravelAgency.scheduledflights)
                     {
                         if (flight.FlightID == flightnum && flight.DepartureDate == dt)
                         {
                             flight.BookSeatFlight(ps, seatnum);
                             foreach (Person per in TravelAgency.people)
                             {
                                 if (per is TravelAgent)
                                 {
                                     TravelAgent ta = per as TravelAgent;
                                     if (ta.EmployeeID == empid)
                                     {
                                         ta.BookTicket(price);
                                         foreach (Person pers in TravelAgency.people)
                                         {
                                             if (pers is Customer)
                                             {
                                                 Customer cust = pers as Customer;
                                                 if (cust.CustomerID == custid)
                                                 {
                                                     cust.ChargeCard(price, cust.CC.expirationDate);
                                                     MessageBox.Show("Passenger " + ps.FirstName + " " + ps.LastName + " was added to flight " + FlightNumbertextBox.Text);
                                                     MessageBox.Show("your balance is now " + cust.CC.Balance);
                                                     MessageBox.Show("Travel Agents Earnings is now: " + ta.Earnings);
                                                 }//charge card
                                                 else
                                                 {
                                                     throw new NotFoundException("not found");
                                                 }
                                             } //if pers is customer
                                         }     //foreach person pers in people
                                     }         //if travel agent ==empid
                                     else
                                     {
                                         throw new NotFoundException("not found");
                                     }
                                 } //if per is travelagent
                             }     //foreach person per in people
                         }         //if flightid and dep date
                         else
                         {
                             TravelAgency.FindFlight(flightnum, dt);
                         } //exception
                     }     //foreach scheduled flight in flights
                 }         //if id==id
                 else
                 {
                     throw new NotFoundException("no such person");
                 } //exception
             }     //if p is passenger
         }         //foreach person p in peopl
     }             //method bookseatonflight
     catch (Exception a)
     {
         MessageBox.Show(a.Message);
     }
 }