コード例 #1
0
        private IPerson GeneratePerson(IFloor floor)
        {
            var otherFloors    = _building.GetFloorsExcept(floor);
            var otherFloorList = otherFloors.ToList();

            if (!otherFloorList.Any())
            {
                throw new InvalidOperationException(nameof(otherFloors));
            }

            var targetFloor = otherFloorList.GetRandomElement();

            return(new Person(floor.FloorNumber, targetFloor.FloorNumber));
        }