Exemplo n.º 1
0
 public Car(int xPos, int yPos, City city, Passenger passenger)
 {
     XPos = xPos;
     YPos = yPos;
     City = city;
     Passenger = passenger;
 }
Exemplo n.º 2
0
        public CityViewModel CreateCityViewModel(City city, int cityWidth, int cityHeight)
        {
            var cityDto = Mapper.Map<CityDto>(city);
            var passengerDto = Mapper.Map<PassengerDto>(city.Passenger);
            var carDto = Mapper.Map<CarDto>(city.Car);

            var cityPositionsLength = cityWidth * cityHeight;
            cityDto.CityPositionDtos = new CityPositionDto[cityPositionsLength];
            for (int i = 0; i < cityPositionsLength; i++)
            {
                cityDto.CityPositionDtos[i] = Mapper.Map<CityPositionDto>(city.CityPositions[i]);
            }

            var carPos = carDto.YPos * cityDto.YMax + carDto.XPos;
            var passengerPos = passengerDto.StartingYPos * cityDto.YMax + passengerDto.StartingXPos;

            cityDto.CityPositionDtos[carPos].CarDto = carDto;
            cityDto.CityPositionDtos[passengerPos].PassengerDto = passengerDto;

            var viewModel = new CityViewModel
            {
                CityDto = cityDto
            };

            return viewModel;
        }
Exemplo n.º 3
0
 public Passenger(int startXPos, int startYPos, int destXPos, int destYPos, City city)
 {
     StartingXPos = startXPos;
     StartingYPos = startYPos;
     DestinationXPos = destXPos;
     DestinationYPos = destYPos;
     City = city;
 }
Exemplo n.º 4
0
        public Car Create(CarType type, int xPos, int yPos, City city, Passenger passenger)
        {
            Car car;

            switch (type)
            {
                case CarType.Sedan:
                    car = new Sedan(xPos, yPos, city, passenger);
                    break;
                case CarType.RaceCar:
                    car = new RaceCar(xPos, yPos, city, passenger);
                    break;
                case CarType.Motorcycle:
                    car = new Motorcycle(xPos, yPos, city, passenger);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            return car;
        }
Exemplo n.º 5
0
        public City Create(ICarFactory carFactory, int cityWidth, int cityHeight)
        {
            int[] BuildingPositions = new[]
            {
                0 * cityWidth + 1,
                0 * cityWidth + 5,
                1 * cityWidth + 3,
                4 * cityWidth + 0,
                4 * cityWidth + 1,
                4 * cityWidth + 8,
                4 * cityWidth + 9,
                6 * cityWidth + 0,
                6 * cityWidth + 1,
                6 * cityWidth + 6,
                6 * cityWidth + 7,
                6 * cityWidth + 8,
                7 * cityWidth + 7,
                7 * cityWidth + 8,
                9 * cityWidth + 0,
                9 * cityWidth + 2,
                9 * cityWidth + 3,
                9 * cityWidth + 4,
            };

            int xCarPos, yCarPos, xPassengerPos, yPassengerPos, xDestinationPos, yDestinationPos;

            GenerateRandomPosition(BuildingPositions, cityWidth, cityHeight, out xCarPos, out yCarPos);
            GenerateRandomPosition(BuildingPositions, cityWidth, cityHeight, out xPassengerPos, out yPassengerPos);
            GenerateRandomPosition(BuildingPositions, cityWidth, cityHeight, out xDestinationPos, out yDestinationPos);

            City city = new City(carFactory, cityWidth, cityHeight, BuildingPositions);
            city.AddCarToCity(CarType.Sedan, xCarPos, yCarPos);
            city.AddPassengerToCity(xPassengerPos, yPassengerPos, xDestinationPos, yDestinationPos);

            return city;
        }
Exemplo n.º 6
0
 public Sedan(int xPos, int yPos, City city, Passenger passenger)
     : base(xPos, yPos, city, passenger)
 {
 }
Exemplo n.º 7
0
 public RaceCar(int xPos, int yPos, City city, Passenger passenger)
     : base(xPos, yPos, city, passenger)
 {
 }
Exemplo n.º 8
0
 public Motorcycle(int xPos, int yPos, City city, Passenger passenger)
     : base(xPos, yPos, city, passenger)
 {
 }