Пример #1
0
        public void ShowParkLotStatusCommands(int command)
        {
            int      parkSpotIx;
            ParkSpot parkSpot;
            string   parkSpotInfo = "";

            switch (command)
            {
            case -1:

                break;

            case 0:
                parkSpotIx = GUI_IO.NumPrompt("Enter parking slot number");
                if (parkSpotIx < 0)
                {
                    return;
                }
                if (parkSpotIx >= parkLot.ParkSpots.Length)
                {
                    Console.WriteLine("The parking spot {0} doesn't exist.", parkSpotIx + 1);
                    return;
                }
                parkSpot = parkLot.ParkSpots[parkSpotIx];
                if (0 == parkSpot.Vehicles.Count)
                {
                    Console.WriteLine("The parking spot is empty.");
                    return;
                }
                for (int i = 0; i < parkSpot.Vehicles.Count; ++i)
                {
                    parkSpotInfo += parkSpot.Vehicles[i].VehicleType + " " + parkSpot.Vehicles[i].RegNum + ", ";
                }
                Console.WriteLine(parkSpotInfo.Substring(0, parkSpotInfo.Length - 2));
                break;

            case 1:
                for (int i = 0; i < parkLot.ParkSpots.Length; ++i)
                {
                    parkSpot = parkLot.ParkSpots[i];
                    if (0 < parkSpot.Vehicles.Count)
                    {
                        parkSpotInfo = (i + 1) + ": ";
                        for (int j = 0; j < parkSpot.Vehicles.Count; ++j)
                        {
                            parkSpotInfo += parkSpot.Vehicles[j].VehicleType + " " + parkSpot.Vehicles[j].RegNum + ", ";
                        }
                        Console.WriteLine(parkSpotInfo.Substring(0, parkSpotInfo.Length - 2));
                    }
                }
                break;

            default:
                break;
            }
        }
Пример #2
0
        public void MoveMenuCommands(int command)
        {
            string  regNum;
            int     toParkSpotIx;
            Vehicle vehicle;

            switch (command)
            {
            case -1:
                break;

            case 1:
                if (RegNumPrompt(out regNum))
                {
                    if (!parkLot.GetVehicle(regNum, out vehicle))
                    {
                        Console.Write("The vehicle doesn't exists in the parking lot.\n");
                        return;
                    }
                    parkLot.GetVehicle(regNum, out vehicle);

                    toParkSpotIx = GUI_IO.NumPrompt("To which parking spot do you want to move the " + vehicle.VehicleType.ToLower() + " " + vehicle.RegNum);
                    if (-1 == toParkSpotIx)
                    {
                        return;
                    }
                    // TODO: check park spot exists
                    //                        Console.Write("To which parking lot do you want to move the {0} {1}: ", vehicle.VehicleType.ToLower(), vehicle.RegNum);
//                        toParkSpotIx = Convert.ToInt32(Console.ReadLine());


                    if (parkLot.Move(vehicle, toParkSpotIx))
                    {
                        Console.WriteLine("Move {0} {1} parked at {2} to parking lot {3}.", vehicle.VehicleType.ToLower(), vehicle.RegNum, vehicle.ParkingSpot + 1, toParkSpotIx + 1);
                    }
                    else
                    {
                        Console.WriteLine("The {0} {1} cannot fit on parking spot: {2}", vehicle.VehicleType.ToLower(), vehicle.RegNum, toParkSpotIx + 1);
                    }
                }
                else
                {
                    Console.WriteLine("There is no vehicle in the parking lot with that registration number!");
                }
                break;

            default:
                break;
            }
        }