Пример #1
0
        public void Occupy(ParkingGarage parkingGarage, ParkingSpace parkingSpace)
        {
            var currentSpace = parkingGarage.FindVehicle(this);

            parkingGarage.ParkVehicle(currentSpace, parkingSpace);
            VehicleParked1 = true;
        }
Пример #2
0
        static void Main(string[] args)
        {
            Garage       garage       = new Garage();
            GarageFloor  garageFloor  = new GarageFloor();
            Dimensions   dimensions   = new Dimensions(1, 1, 1);
            ParkingSpace parkingSpace = new ParkingSpace(dimensions);

            garageFloor.AddSpace(parkingSpace);

            for (int i = 0; i < 1; i++)
            {
                garage.AddFloor(garageFloor);
            }

            Car car = new Car(dimensions, "DRIV3R");

            garage.FloorList[0].ParkingSpaces[0].AddVehicle(car);

            foreach (var space in garage.IsSpace(car))
            {
                Console.WriteLine("There is a space on floor");
                Console.WriteLine(garage.GetFloorNumber(garage.GetFloorFromSpace(space)));
            }
            ;
        }
Пример #3
0
        public ParkingSpace FindVehicle(VehicleParked vehicle)
        {
            for (var spaces = 0; spaces < GarageSettings.GarageSize; spaces++)
            {
                if (parkingGarage[spaces, spaces] == vehicle)
                {
                    return(ParkingSpace.At(parkingSpace1: 2));
                }
            }

            throw new ArgumentException("The car is not in the garage");
        }
Пример #4
0
        public void ParkVehicle(ParkingSpace from, ParkingSpace to)
        {
            var parkingSpace = parkingGarage[from.ParkingSpace1, from.ParkingSpace1];

            if (parkingSpace == null)
            {
                return;
            }


            //Making space about to be used as occupied

            if (parkingGarage[to.ParkingSpace1, to.ParkingSpace1] != null)
            {
                SpaceOccupied(parkingGarage[to.ParkingSpace1, to.ParkingSpace1]);
            }
            //Marking space about to be empty as empty
            parkingGarage[to.ParkingSpace1, to.ParkingSpace1] = parkingGarage[to.ParkingSpace1, to.ParkingSpace1];
        }
Пример #5
0
 public void AddSpace(ParkingSpace parkingSpace, VehicleParked vehicle)
 {
     parkingGarage[parkingSpace.ParkingSpace1, parkingSpace.ParkingSpace1] = vehicle;
 }
Пример #6
0
 public bool Equals(ParkingSpace parkingSpace)
 {
     return(ParkingSpace1 == parkingSpace.ParkingSpace1);
 }