public SlotGroup(Roaster roaster, Timer timer, Lever lever, int numberOfSlotPerGroup) { for (int idx = 0; idx < numberOfSlotPerGroup; idx++) { this.slots.Add(new Slot(roaster, timer, lever)); } }
public Slot(Roaster roaster, Timer timer, Lever lever) { this.roaster = roaster; this.lever = lever; timer?.TimeoutHandlers.Add(this); lever?.LeverStatusChangedHandlers.Add(this); }
public Roaster(int numberGroups, int numberOfSlotPerGroup) { // verify input & count match for (int idx = 0; idx < numberGroups; idx++) { Lever lever = new Lever(); Timer timer = new Timer(this); timer.TimeoutHandlers.Add(lever); lever.LeverStatusChangedHandlers.Add(timer); SlotGroup group = new SlotGroup(this, timer, lever, numberOfSlotPerGroup); this.groups.Add(group); this.levers.Add(lever); this.timers.Add(timer); } }