using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DesignModel { public interface Factory { JS createjs(); } public class JS { public int NumA { get; set; } public int NumB { get; set; } public virtual int GetResult() { return 0; } } public class Add1 : JS { public override int GetResult() { return NumA + NumB; } } public class Sub1 : JS { public override int GetResult() { return NumA - NumB; } } public class AddFactory : Factory { public JS createjs() { return new Add1(); } } public class SubFactory: Factory { public JS createjs() { return new Sub1(); } } }