Exemplo n.º 1
0
 private static void displayRiders(RideList ride)
 {
     Console.WriteLine("\nSource:{0}\n Destination:{1}\n Type of Vehicle:{2}\n Seats Available:{3}\n Name: {4}\n Phone:{5}\n Gender:{6}\n", ride.source, ride.destination, ride.typeOfVehicle == 2 ? "Two Wheeler" : "Four Wheeler", ride.seatsAvailableCount - ride.riders.Count, ride.name, ride.phone, ride.gender);
     if (ride.riders.Count > 0)
     {
         Console.WriteLine("Riders:");
         foreach (Riders rider in ride.riders)
         {
             Console.WriteLine(" \n\tName: {0} \n\tPhone: {1} \n\tGender: {2}", rider.name, rider.phone, rider.gender);
         }
     }
 }
Exemplo n.º 2
0
        private static void offerRide()
        {
            int typeOfVehicle;
            int seatsAvailableCount;

            Console.WriteLine("Source");
            string source = Console.ReadLine();

            Console.WriteLine("Destination");
            string destination        = Console.ReadLine();
            bool   vehicleTypeCheck   = true;
            bool   availableSeatCheck = true;

            do
            {
                Console.WriteLine("Type of vehicle \n 2. Two Wheeler \n 4. Four Wheeler");
                if (isValidInt(out typeOfVehicle))
                {
                    if (typeOfVehicle == 2 || typeOfVehicle == 4)
                    {
                        vehicleTypeCheck = false;
                    }
                    else
                    {
                        Console.WriteLine("Please enter 2 for Two Wheeler or 4 for Four Wheeler\n");
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Input\n");
                }
            } while (vehicleTypeCheck);

            do
            {
                Console.WriteLine("Number of available seats");
                if (isValidInt(out seatsAvailableCount))
                {
                    if ((seatsAvailableCount > 0) && (typeOfVehicle - seatsAvailableCount > 0))
                    {
                        availableSeatCheck = false;
                    }
                    else
                    {
                        Console.WriteLine("Please enter correct information.\n");
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Input\n");
                }
            } while (availableSeatCheck);

            Console.WriteLine("Name");
            string name = Console.ReadLine();

            Console.WriteLine("Phone");
            string phone = Console.ReadLine();

            Console.WriteLine("Gender");
            string gender = Console.ReadLine();

            RideList pet = new RideList {
                source = source, destination = destination, typeOfVehicle = typeOfVehicle, seatsAvailableCount = seatsAvailableCount, riders = new List <Riders>(), name = name, phone = phone, gender = gender
            };

            rideList.Add(pet);
            Console.WriteLine("\nYour request has been posted\n");
        }