-
-
Save hatelove/e556a97830b54eea76c4945021f3af3e to your computer and use it in GitHub Desktop.
Factory Method sample code
This file contains 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 Blackcat_V2 : IShipper | |
{ | |
private double _discount; | |
private Blackcat_V2() | |
{ | |
} | |
public static IShipper CreateBlackcatV2(double discount) | |
{ | |
var blackcatV2 = new Blackcat_V2(); | |
blackcatV2.SetDiscount(discount); | |
return blackcatV2; | |
} | |
private void SetDiscount(double discount) | |
{ | |
this._discount = discount; | |
} | |
public double CalculateFee() | |
{ | |
return 100 * this._discount; | |
} | |
} | |
public interface IShipper | |
{ | |
double CalculateFee(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment