private static IElevatorButton GetElevatorButton(ButtonFactory btnFactory, int i) { IElevatorButton btn = (IElevatorButton)btnFactory.CreateButton(ButtonType.ElevatorButton); btn.ButtonID = i; btn.ButtonName = i.ToString(); btn.Description = string.Format("Press this button to go to Floor No.{0}", btn.ButtonID); return(btn); }
private static IElevatorButton[] GetElevatorButtons(int bottomFloor, int topFloor) { IElevatorButton[] elevatorButtons = new ElevatorButton[topFloor + Math.Abs(bottomFloor) + 1]; int index = 0; ButtonFactory btnFactory = new ButtonFactory(); for (int i = bottomFloor; i <= topFloor; i++) { elevatorButtons[index++] = GetElevatorButton(btnFactory, i); } return(elevatorButtons); }