예제 #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);
 }