Esempio n. 1
0
        public bool AddFordon(int typeOfVehicle, Vehicle fordon, string color, string brand)

        {
            if (typeOfVehicle == 1)
            {
                Car Bil = new Car(fordon, color);
                Fordon.Add(Bil);
                availableSize = availableSize - Bil.size;
                return(true);
            }
            if (typeOfVehicle == 2)
            {
                MC MB = new MC(fordon, brand);
                Fordon.Add(MB);
                availableSize = availableSize - MB.size;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public bool MoveVehicle(string regnr, int position, int typeOfVehicle)
        {
            int result = FindVehicle(regnr);

            if (result != -1)
            {
                for (int s = 0; s <= ParkingSpace.Length - 1; s++)
                {
                    if ((s + 1) == position)
                    {
                        if (typeOfVehicle == 1)//if its a CAR
                        {
                            if (ParkingSpace[s].availableSize == 4)
                            {
                                Vehicle fordon = new Vehicle(regnr, 0);
                                Car     C1     = (Car)ParkingSpace[result].FordonA[0];

                                RemoveVehicle(regnr);
                                ParkingSpace[s].AddFordon(typeOfVehicle, fordon, C1.color, "");

                                Console.WriteLine("CAR " + regnr + "was moved to position " + position);
                                Console.ReadLine();
                                return(true);
                            }
                            else
                            {
                                Console.WriteLine("The position is not available");
                            }
                        }
                        if (typeOfVehicle == 2)
                        {
                            if (ParkingSpace[s].availableSize >= 2)
                            {
                                Vehicle fordon    = new Vehicle(regnr, 0);
                                MC      M1        = (MC)ParkingSpace[result].FordonA[0];
                                string  brandName = M1.brand;
                                if (M1.regnr != regnr)
                                {
                                    MC M2 = (MC)ParkingSpace[result].FordonA[1];
                                    brandName = M2.brand;
                                }

                                RemoveVehicle(regnr);
                                ParkingSpace[s].AddFordon(typeOfVehicle, fordon, "", brandName);

                                Console.WriteLine("MC " + regnr + "was moved to position " + position);
                                Console.ReadLine();
                                return(true);
                            }
                            else
                            {
                                Console.WriteLine("The position is not available");
                            }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Vehicle not yet parked");
            }
            return(false);
        }