/// <summary> /// Takes 3 arguments: <paramref name="betSort"/>, <paramref name="amount"/>, <paramref name="dogToWin"/> and in switch statement base on <paramref name="betSort"/> decides /// which bet instance should be created. /// </summary> /// <param name="betSort"> Enum type which specifies what sort of bet should be returned.</param> /// <param name="amount"> Amount of the bet.</param> /// <param name="dogToWin"> Dog number on which the bet has been placed.</param> /// <seealso cref="BetSort"/> /// <returns> New bet instance with initialized fields.</returns> public virtual IBetSort CreateBet(BetSort betSort, decimal amount, int dogToWin) { IBetSort bet = null; switch (betSort) { case BetSort.dummyBet: bet = new BetDummy(); break; case BetSort.standartBet: bet = new BetStandard(amount, dogToWin); break; case BetSort.handicapBet: bet = new BetHandicap(amount, dogToWin); break; } return(bet); }
/// <summary> /// Clears bet object by overriding it with bet instance of <see cref="BetDummy"/> class. /// </summary> /// <remarks> /// <see cref="BetDummy"/> class ensures that object is overriden and garbage collected. /// <see cref="BetDummy"/> also provides safe implementation of <see cref="IBetSort"/>. /// </remarks> public void ClearBet() { betSort = betFactory.CreateBet(BetFactory.BetSort.dummyBet, 0, 0); }