Пример #1
0
        public static void userInput(GarageManager manager, Vehicle vehicle)
        {
            string name;
            string regNr;
            string color;
            string fuel = "nil";
            int    seats;
            int    length;
            int    tyres    = 0;
            int    cc       = 0;
            int    engines  = 0;
            int    thrust   = 0;
            int    altitude = 0;
            bool   output;
            bool   loop = true;

            do
            {
                Console.Write("Enter Vehicle's Name: ");
                name   = Console.ReadLine();
                output = inputValidationCheckString(name);
                if (output == true)
                {
                    break;
                }

                Console.Write("\nEnter Vehicle's Reg.No.: ");
                regNr  = Console.ReadLine();
                output = inputValidationCheckString(regNr);
                if (output == true)
                {
                    break;
                }

                Console.Write("\nEnter Vehicle's Color: ");
                color  = Console.ReadLine();
                output = inputValidationCheckString(color);
                if (output == true)
                {
                    break;
                }

                Console.Write("\nEnter Vehicle's No. of Seats: ");
                string seatInput = Console.ReadLine();
                seats = inputValidationCheckInt(seatInput);
                if (seats == 0)
                {
                    break;
                }

                Console.Write("\nEnter Vehicle's length(cm): ");
                string lengthInput = Console.ReadLine();
                length = inputValidationCheckInt(lengthInput);
                if (length == 0)
                {
                    break;
                }

                if (vehicle.VehicleTypeName == "Bicycle")
                {
                    Console.Write("\nEnter Vehicle's No. of Tyres: ");
                    string tyresInput = Console.ReadLine();
                    tyres = inputValidationCheckInt(tyresInput);
                    if (tyres == 0)
                    {
                        break;
                    }
                }

                if (vehicle.VehicleTypeName == "Car" || vehicle.VehicleTypeName == "Motorcycle" || vehicle.VehicleTypeName == "Bus")
                {
                    Console.WriteLine("vehicle type " + vehicle.VehicleTypeName);

                    Console.Write("\nEnter Vehicle's Engine Capacity(CC): ");
                    string ccInput = Console.ReadLine();
                    cc = inputValidationCheckInt(ccInput);
                    if (cc == 0)
                    {
                        break;
                    }

                    Console.Write("\nEnter Vehicle's Fuel-Type(Petrol/Diesel/Jetfuel): ");
                    fuel   = Console.ReadLine();
                    output = inputValidationCheckString(fuel);
                    if (output == true)
                    {
                        break;
                    }

                    Console.Write("\nEnter Vehicle's No. of Tyres: ");
                    string tyresInput = Console.ReadLine();
                    tyres = inputValidationCheckInt(tyresInput);
                    if (tyres == 0)
                    {
                        break;
                    }
                }

                if (vehicle.VehicleTypeName == "Airoplane" || vehicle.VehicleTypeName == "Helicopter")
                {
                    Console.Write("\nEnter Vehicle's Fuel-Type(Petrol/Diesel/Jetfuel): ");
                    fuel   = Console.ReadLine();
                    output = inputValidationCheckString(fuel);
                    if (output == true)
                    {
                        break;
                    }

                    Console.Write("\nEnter Vehicle's No. of Engines: ");
                    string enginesInput = Console.ReadLine();
                    engines = inputValidationCheckInt(enginesInput);
                    if (engines == 0)
                    {
                        break;
                    }

                    Console.Write("\nEnter Vehicle's No. of Tyres: ");
                    string tyresInput = Console.ReadLine();
                    tyres = inputValidationCheckInt(tyresInput);
                    if (tyres == 0)
                    {
                        break;
                    }


                    Console.Write("\nEnter Vehicle's Total Thrust(Pounds): ");
                    string thrustInput = Console.ReadLine();
                    thrust = inputValidationCheckInt(thrustInput);
                    if (thrust == 0)
                    {
                        break;
                    }

                    Console.Write("\nEnter Vehicle's Flight Altitude(Feet): ");
                    string altitudeInput = Console.ReadLine();
                    altitude = inputValidationCheckInt(altitudeInput);
                    if (altitude == 0)
                    {
                        break;
                    }
                }

                manager.parkVehicle(vehicle, name.ToUpper(), regNr.ToUpper(), color.ToUpper(), length, seats, tyres, cc, fuel.ToUpper(), engines, thrust, altitude);
                loop = false;
            } while (loop);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Garage garage = new Garage();

            Console.WriteLine("Garage Capacity: " + garage.Capacity);

            var           slots   = garage.ParkingSlots;
            GarageManager manager = new GarageManager(slots);

            // Garage garage0 = manager.createParkingSlots(100);
            // Console.WriteLine("Motorcycle Parking Slots: " + garage0.ParkingSlots);

            Console.WriteLine("Slot Available: " + manager.Count);


            var car1        = new Car("Mazda");
            var car2        = new Car("Volvo");
            var car3        = new Car("Audi");
            var car4        = new Car("Toyota");
            var motorCycle1 = new Motorcycle("Honda");
            var motorCycle2 = new Motorcycle("BMW");
            var motorCycle3 = new Motorcycle("Vespa");
            var motorCycle4 = new Motorcycle("Hero");
            var motorboat   = new Motorboat("Zero");
            var ship1       = new Ship("Viking");
            var ship2       = new Ship("Jordgården");
            var ship3       = new Ship("Siljaline");
            var bicycle1    = new Bicycle("City");
            var bicycle2    = new Bicycle("City");
            var bicycle3    = new Bicycle("Tedy");
            var bicycle4    = new Bicycle("Sport");

            manager.parkVehicle(car1);
            manager.parkVehicle(car2);
            manager.parkVehicle(car3);
            manager.parkVehicle(car4);
            manager.parkVehicle(motorCycle1);
            manager.parkVehicle(motorCycle2);
            manager.parkVehicle(motorCycle3);
            manager.parkVehicle(motorCycle4);
            manager.parkVehicle(motorboat);
            manager.parkVehicle(ship1);
            manager.parkVehicle(ship2);
            manager.parkVehicle(ship3);
            manager.parkVehicle(bicycle1);
            manager.parkVehicle(bicycle2);
            manager.parkVehicle(bicycle3);
            manager.parkVehicle(bicycle4);


            Vehicle[] array = manager.listParkedVehicle();
            // Console.WriteLine("P N: A" + pN);

            Console.WriteLine("Vehicle Parked:");
            Console.WriteLine("{0,-15}{1,-10}{2,-10}", "Vehicle Type", "P.No", "Vehicle Name");

            foreach (Vehicle vehicle in array)
            {
                //Console.WriteLine("{0,10}{1,10}{2,10}", "Vehicle Type", "P N: A", "Vehicle Name");
                Console.WriteLine("{0,-15}{1,-10}{2,-10}", vehicle.vehicleType, vehicle.pN, vehicle.vehicleName);
//              Console.WriteLine("Motorcycle List: " + vehicle.VehicleName);
            }
            Console.WriteLine();
            Console.WriteLine("Slot Available: " + manager.Count);
            Console.WriteLine(
                );
            manager.unparkVehicle(motorCycle4);
            manager.unparkVehicle(car1);
            manager.unparkVehicle(bicycle4);

            Vehicle[] array1 = manager.listParkedVehicle();

            Console.WriteLine("Vehicle Parked:");
            Console.WriteLine("{0,-15}{1,-10}{2,-10}", "Vehicle Type", "P.No", "Vehicle Name");

            foreach (Vehicle vehicle in array1)
            {
                //Console.WriteLine("{0,10}{1,10}{2,10}", "Vehicle Type", "P N: A", "Vehicle Name");
                Console.WriteLine("{0,-15}{1,-10}{2,-10}", vehicle.vehicleType, vehicle.pN, vehicle.vehicleName);
                //              Console.WriteLine("Motorcycle List: " + vehicle.VehicleName);
            }
            Console.WriteLine();
            Console.WriteLine("Slot Available: " + manager.Count);

            /*   Vehicle[] array1 = manager.listParkedVehicle();
             * //Console.WriteLine("List: " + manager.listParkedVehicle());
             *
             * Console.WriteLine("Count: " + manager.Count);
             * Console.WriteLine("Vehicle Type      :     Vehicle Name");
             *
             * foreach (Vehicle vehicle in array1)
             * {
             *     Console.WriteLine(vehicle.vehicleType + "   :    " + vehicle.vehicleName);
             *  // Console.WriteLine("Motorcycle List: " + vehicle.VehicleName);
             *
             * }*/
        }