Ejemplo n.º 1
0
 /*---------------------------------------------------------
 * Constructor
 * Parameters:
 *   f, l - first and lastnames
 *   c0, s0 - origin city and statecode
 *   c1, s1 - destination city and statecode
 *
 *--------------------------------------------------------*/
 public Passenger(string f, string l, string c0, string s0, string c1, string s1)
 {
     this.firstname   = f;
     this.lastname    = l;
     this.origin      = Geolocator.findCoords(c0, s0);
     this.destination = Geolocator.findCoords(c1, s1);
     this.distance    = Math.Round(Geolocator.getDistance(this.origin, this.destination), 2);
     this.price       = Math.Round(this.distance * 1.25, 2);
 }
Ejemplo n.º 2
0
    /*---------------------------------------------------------
    * Method: getPassengers
    *
    * Purpose: Reads in passengers via keyboard input
    *
    * Returns: List of Passenger objects
    *--------------------------------------------------------*/
    static public List <Passenger> getPassengers()
    {
        List <Passenger> people = new List <Passenger>();

        Console.Clear();
        Console.WriteLine("Flight Itinerary Builder Program \n");
        Console.Write("Do you want to add a passenger to your itinerary list (Y/N)? ");
        string line = Console.ReadLine();

        while (line.ToLower().Equals("y"))
        {
            Console.Write("First Name: ");
            string fname = Console.ReadLine();
            Console.Write("Last Name: ");
            string lname = Console.ReadLine();

            Location opos = new Location(-1, -1, "", "");
            while (opos.latitude == -1)
            {
                Console.Write("Origination City: ");
                string ocity = Console.ReadLine();
                Console.Write("Origination State (two letter code): ");
                string ostate = Console.ReadLine();
                opos = Geolocator.findCoords(ocity, ostate);
                if (opos.latitude == -1)
                {
                    Console.WriteLine("\t ***CITY NOT ON FILE***");
                }
            }

            Location dpos = new Location(-1, -1, "", "");
            while (dpos.latitude == -1)
            {
                Console.Write("Destination City: ");
                string dcity = Console.ReadLine();
                Console.Write("Destination State (two letter code): ");
                string dstate = Console.ReadLine();
                dpos = Geolocator.findCoords(dcity, dstate);
                if (dpos.latitude == -1)
                {
                    Console.WriteLine("\t ***CITY NOT ON FILE***");
                }
            }

            Passenger p = new Passenger(fname, lname, opos, dpos);
            people.Add(p);

            Console.Write("Do you want to add a passenger to your itinerary list (Y/N)? ");
            line = Console.ReadLine();
        }
        Console.WriteLine("** GENERATING ITINERARY **");
        return(people);
    }