This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Test() | |
{ | |
var a = new ATMDispenser(100, 1); | |
var b = new ATMDispenser(50, 2); | |
var c = new ATMDispenser(20, 5); | |
a.SetNext(b); | |
b.SetNext(c); | |
var x = a.Check(140); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ATMDispenserAbstract | |
{ | |
protected ATMDispenserAbstract Next; | |
public void SetNext(ATMDispenserAbstract next) | |
{ | |
Next = next; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class RecommendedVideo | |
{ | |
protected RecommendedVideo Next; | |
public void SetNext(RecommendedVideo next) | |
{ | |
Next = next; | |
} | |
public abstract string GetVideo(int age); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Test() | |
{ | |
var polandTaxCalculator = new PolandTaxCalculator(); | |
var germanyTaxCalculator = new GermanyTaxCalculator(); | |
var norwayTaxCalculator = new NorwayTaxCalculator(); | |
var franceTaxCalculator = new FranceTaxCalculator(); | |
var russiaTaxCalculator = new RussiaTaxCalculator(); | |
polandTaxCalculator.SetNext(germanyTaxCalculator); | |
germanyTaxCalculator.SetNext(norwayTaxCalculator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class TaxCalculator | |
{ | |
protected TaxCalculator Next; | |
public void SetNext(TaxCalculator next) | |
{ | |
Next = next; | |
} | |
public abstract double GetValue(double total, string countryName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TaxCalculator | |
{ | |
private readonly string countryName; | |
public TaxCalculator(string countryName) | |
{ | |
this.countryName = countryName; | |
} | |
public double GetValue(double total) |