Exemple #1
0
 public void AlotParking()
 {
     try
     {
         CarTypes car = new CarTypes();
         Console.WriteLine("Wait at security gate for alotment");
         if (vehiclequeue > 1)
         {
             Console.WriteLine("Other Vehicle is in process");
         }
         else
         {
             Console.WriteLine("Please enter the vehicle type");
             string readvehicletype = Console.ReadLine().ToLower();
             ParkingLotType(car, readvehicletype);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace + "\n" + ex.InnerException);
     }
 }
Exemple #2
0
        private void ParkingLotType(CarTypes car, string readvehicletype)
        {
            List <int> nos = new List <int>();

            try
            {
                if (car != null || !string.IsNullOrWhiteSpace(readvehicletype))
                {
                    switch (readvehicletype)
                    {
                    case "hatchback":
                        Console.WriteLine("Type-" + car.hatchback);
                        Console.WriteLine("provided parking space is" + parkingsize.small);
                        small = small - 1;
                        Console.WriteLine("The available parking total lots are" + "\n" + "small-" + small + "\n" + "medium-" + medium + "\n" + "large-" + large);
                        vehiclequeue  = vehiclequeue + 1;
                        availableslot = availableslot + 1;
                        //nos.Add(availableslot+1);
                        checkremainingslot(availableslot);
                        if (small == 0)
                        {
                            Console.WriteLine("provided parking space is" + parkingsize.medium);
                            medium        = medium - 1;
                            availableslot = availableslot + 1;
                            Console.WriteLine("The available parking total lots are" + "\n" + "small-" + small + "\n" + "medium-" + medium + "\n" + "large-" + large);
                            vehiclequeue = vehiclequeue + 1;
                        }
                        else if (medium == 0)
                        {
                            Console.WriteLine("parking space for hatchback is full");
                        }
                        break;

                    case "sedan":
                        Console.WriteLine("Type-" + car.sedan);
                        Console.WriteLine("provided parking space is" + parkingsize.medium);
                        medium = medium - 1;
                        Console.WriteLine("The available parking total lots are" + "\n" + "small-" + small + "\n" + "medium-" + medium + "\n" + "large-" + large);
                        vehiclequeue  = vehiclequeue + 1;
                        availableslot = availableslot + 1;
                        if (medium == 0)
                        {
                            Console.WriteLine("provided parking space is" + parkingsize.large);
                            medium        = medium - 1;
                            availableslot = availableslot + 1;
                            Console.WriteLine("The available parking total lots are" + "\n" + "small-" + small + "\n" + "medium-" + medium + "\n" + "large-" + large);
                            vehiclequeue = vehiclequeue + 1;
                        }
                        else if (large == 0)
                        {
                            Console.WriteLine("parking space for sedan is full");
                        }
                        break;

                    case "suv":
                        Console.WriteLine("Type-" + car.suv);
                        Console.WriteLine("provided parking space is" + parkingsize.large);
                        large         = large - 1;
                        availableslot = availableslot + 1;
                        Console.WriteLine("The available parking total lots are" + "\n" + "small-" + small + "\n" + "medium-" + medium + "\n" + "large-" + large);
                        vehiclequeue = vehiclequeue + 1;
                        if (large == 0)
                        {
                            Console.WriteLine("parking space for suv is full");
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace + "\n" + ex.InnerException);
            }
        }