Beispiel #1
0
 private void CheckForNextDiscountState()
 {
     if (currentState == fivePercentCard && currentState.payedInTotal >= 5000)
     {
         tenPercentCard.payedInTotal = currentState.payedInTotal;
         currentState = tenPercentCard;
         Console.WriteLine("Your card discount value has been increased to 10%.");
     }
     else if (currentState == tenPercentCard && currentState.payedInTotal >= 10000)
     {
         fifteenPercentCard.payedInTotal = currentState.payedInTotal;
         currentState = fifteenPercentCard;
         Console.WriteLine("Your card discount value has been increased to 15%.");
     }
 }
Beispiel #2
0
 public DiscountCardContext()
 {
     // Initialize to 5% card as initial state.
     currentState = fivePercentCard;
 }